Class: Keen::HTTP::Async
- Inherits:
-
Object
- Object
- Keen::HTTP::Async
- Defined in:
- lib/keen/http.rb
Instance Method Summary collapse
-
#initialize(host, port, options = {}) ⇒ Async
constructor
A new instance of Async.
- #post(options) ⇒ Object
Constructor Details
#initialize(host, port, options = {}) ⇒ Async
Returns a new instance of Async.
18 19 20 21 22 23 24 25 26 |
# File 'lib/keen/http.rb', line 18 def initialize(host, port, ={}) if defined?(EventMachine) && EventMachine.reactor_running? require 'em-http-request' else raise Error, "An EventMachine loop must be running to use publish_async calls" end @host, @port, @http_options = host, port, end |
Instance Method Details
#post(options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/keen/http.rb', line 28 def post() path, headers, body = .values_at( :path, :headers, :body) uri = "https://#{@host}:#{@port}#{path}" http_client = EventMachine::HttpRequest.new(uri, @http_options) http_client.post( :body => body, :head => headers ) end |