Module: Skooma::EnvMapper

Defined in:
lib/skooma/env_mapper.rb

Constant Summary collapse

PLAIN_HEADERS =
%w[CONTENT_LENGTH CONTENT_TYPE].freeze
REGEXP_HTTP =
/^HTTP_/.freeze

Class Method Summary collapse

Class Method Details

.call(env, response = nil, with_response: true, with_request: true) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/skooma/env_mapper.rb', line 9

def call(env, response = nil, with_response: true, with_request: true)
  result = {
    "method" => env["REQUEST_METHOD"].downcase,
    "path" => env["action_dispatch.original_path"] || env["PATH_INFO"]
  }
  result["request"] = map_request(env) if with_request
  result["response"] = map_response(response) if response && with_response

  result
end