Module: Tom::Http

Defined in:
lib/http.rb

Class Method Summary collapse

Class Method Details

.make_request(method, url, options = {}) ⇒ Object

Makes a http request of the given method to the given url. Passes the options on to EM::HttpRequest.put (or whatever method has to be called) and does some error handling and works around some EM:HttpRequest oddities (see handle_errors).

Parameters:

  • method (Symbol)

    Request method, lowercase, you know the deal

  • url (String)

    Full url (e.g. host + path)

  • options (Hash) (defaults to: {})

    Options to pass to EM::HttpRequest’s get/put/post/delete method



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/http.rb', line 14

def self.make_request(method, url, options = {})
  Tom::Log.logger.info "     curl -X#{method.upcase} -d '#{options[:body]}' #{url}"

  conn = EM::HttpRequest.new(url, connection_options)
  result  = conn.send(method, options)

  # Disabling this for a while
  # handle_errors(method, url, result)

  result
end