The Rack env build method is too large that hard to extend new behaviors. Add Hanami::Lambda::Env to improve it.
|
def build_env(event, headers, context) |
|
{ |
|
::Rack::REQUEST_METHOD => event["httpMethod"], |
|
::Rack::PATH_INFO => event["path"] || "", |
|
::Rack::VERSION => ::Rack::VERSION, |
|
::Rack::RACK_INPUT => StringIO.new(event["body"] || ""), |
|
::Hanami::Lambda::LAMBDA_EVENT => event, |
|
::Hanami::Lambda::LAMBDA_CONTEXT => context |
|
}.tap do |env| |
|
content_type = headers.delete("Content-Type") || |
|
headers.delete("content-type") || |
|
headers.delete("CONTENT_TYPE") |
|
env["CONTENT_TYPE"] = content_type if content_type |
|
end.merge(headers.transform_keys { |k| "HTTP_#{k.upcase.tr('-', '_')}" }) |
|
end |
The Rack env build method is too large that hard to extend new behaviors. Add
Hanami::Lambda::Envto improve it.hanami-lambda/lib/hanami/lambda/rack.rb
Lines 43 to 57 in 8592279