Class: Measures::Transport::HTTP
- Inherits:
-
Object
- Object
- Measures::Transport::HTTP
- Defined in:
- lib/measures/transport/http.rb
Instance Method Summary collapse
-
#initialize(host, port) ⇒ HTTP
constructor
A new instance of HTTP.
- #send(data) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ HTTP
Returns a new instance of HTTP.
8 9 10 11 |
# File 'lib/measures/transport/http.rb', line 8 def initialize(host, port) @host = host @port = port end |
Instance Method Details
#send(data) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/measures/transport/http.rb', line 13 def send(data) client = Faraday.new(url: URI::HTTP.build(host: @host, port: @port)) do |c| c.request :json c.adapter Faraday.default_adapter end client.post do |req| req.url "/" req.headers["Content-Type"] = "application/json" req.body = data end end |