Module: Evil::Client::Connection

Extended by:
Connection
Included in:
Connection
Defined in:
lib/evil/client/connection.rb

Overview

Object that sends rack-compatible request environment to remote API, and wraps a response into rack-compatible array of [status, headers, body].

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Array

Makes the request by taking rack env and returning rack response

Parameters:

  • env (Hash<String, Object>)

    Rack environment

Returns:

  • (Array)

    Rack-compatible response



16
17
18
19
20
21
22
23
24
# File 'lib/evil/client/connection.rb', line 16

def call(env)
  request = Rack::Request.new(env)
  with_logger_for request do
    open_http_connection_for request do |http|
      res = http.request build_from(request)
      [res.code.to_i, Hash(res.header), Array(res.body)]
    end
  end
end