Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to add Rack env builder #4

Open
elct9620 opened this issue May 30, 2024 · 0 comments · May be fixed by #6
Open

Refactor to add Rack env builder #4

elct9620 opened this issue May 30, 2024 · 0 comments · May be fixed by #6

Comments

@elct9620
Copy link
Owner

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

requiemformemories added a commit to requiemformemories/hanami-lambda that referenced this issue Jun 25, 2024
@requiemformemories requiemformemories linked a pull request Jun 25, 2024 that will close this issue
requiemformemories added a commit to requiemformemories/hanami-lambda that referenced this issue Jun 25, 2024
requiemformemories added a commit to requiemformemories/hanami-lambda that referenced this issue Jun 25, 2024
requiemformemories added a commit to requiemformemories/hanami-lambda that referenced this issue Jun 26, 2024
requiemformemories added a commit to requiemformemories/hanami-lambda that referenced this issue Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant