Class: HttpMonkey::Middlewares::HttpRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/http_monkey/middlewares/http_request.rb

Overview

Main App middleware Responsible to make HTTP request

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/http_monkey/middlewares/http_request.rb', line 7

def self.call(env)
  unless env.is_a?(HttpMonkey::Client::Environment)
    env = HttpMonkey::Client::Environment.new(env)
  end
  _, request, client = env['http_monkey.request']

  method = env.request_method
  request.url = env.uri
  request.headers = env.http_headers
  request.body = env['rack.input']

  response = HTTPI.request(method, request, client.net_adapter)
  [response.code, response.headers, response.body]
end