Class: Flare::HttpTransport
- Inherits:
-
Object
- Object
- Flare::HttpTransport
- Defined in:
- lib/flare/http_transport.rb
Overview
Tiny HTTP wrapper used by TraceExporter (and anything else that wants to PUT/POST without pulling in a heavy client). Designed for injection at the boundary so tests can swap in a recording fake; no other moving parts.
Defined Under Namespace
Classes: Response
Constant Summary collapse
- DEFAULT_OPEN_TIMEOUT =
2- DEFAULT_READ_TIMEOUT =
5- DEFAULT_WRITE_TIMEOUT =
5
Instance Method Summary collapse
- #get(url, headers = {}) ⇒ Object
-
#initialize(open_timeout: DEFAULT_OPEN_TIMEOUT, read_timeout: DEFAULT_READ_TIMEOUT, write_timeout: DEFAULT_WRITE_TIMEOUT) ⇒ HttpTransport
constructor
A new instance of HttpTransport.
- #post(url, body, headers = {}) ⇒ Object
- #put(url, body, headers = {}) ⇒ Object
Constructor Details
#initialize(open_timeout: DEFAULT_OPEN_TIMEOUT, read_timeout: DEFAULT_READ_TIMEOUT, write_timeout: DEFAULT_WRITE_TIMEOUT) ⇒ HttpTransport
Returns a new instance of HttpTransport.
23 24 25 26 27 28 29 |
# File 'lib/flare/http_transport.rb', line 23 def initialize(open_timeout: DEFAULT_OPEN_TIMEOUT, read_timeout: DEFAULT_READ_TIMEOUT, write_timeout: DEFAULT_WRITE_TIMEOUT) @open_timeout = open_timeout @read_timeout = read_timeout @write_timeout = write_timeout end |
Instance Method Details
#get(url, headers = {}) ⇒ Object
31 32 33 |
# File 'lib/flare/http_transport.rb', line 31 def get(url, headers = {}) request(url, nil, headers, Net::HTTP::Get) end |
#post(url, body, headers = {}) ⇒ Object
39 40 41 |
# File 'lib/flare/http_transport.rb', line 39 def post(url, body, headers = {}) request(url, body, headers, Net::HTTP::Post) end |
#put(url, body, headers = {}) ⇒ Object
35 36 37 |
# File 'lib/flare/http_transport.rb', line 35 def put(url, body, headers = {}) request(url, body, headers, Net::HTTP::Put) end |