Skip to content

Pass Lambda Context to web app in a new header#248

Merged
bnusunny merged 2 commits intoaws:mainfrom
mbfreder:lambda-context
Jul 3, 2023
Merged

Pass Lambda Context to web app in a new header#248
bnusunny merged 2 commits intoaws:mainfrom
mbfreder:lambda-context

Conversation

@mbfreder
Copy link
Copy Markdown
Contributor

@mbfreder mbfreder commented Jul 3, 2023

Issue #, if available: #244

Description of changes:

Made Lambda Context available to web apps in a new header (x-amzn-lambda-context).

Note : The implementation broke some tests because the LambdaRequest object used to send the request to the mock server doesn't have a lambda context, resulting in an error ("Request did not contain a lambda context") when "let lambda_context = &event.lambda_context();" is called. I fixed this by replacing LambdaRequest with Request, which allows adding the lambda context.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@bnusunny
Copy link
Copy Markdown
Contributor

bnusunny commented Jul 3, 2023

Thanks for the contribution.

Could you add one test to check if the new header is present? You can do it when creating the mock server.

        when.method(GET)
            .path("/")
            .header_exists("x-amzn-lambda-context");

@mbfreder
Copy link
Copy Markdown
Contributor Author

mbfreder commented Jul 3, 2023

Thanks for the contribution.

Could you add one test to check if the new header is present? You can do it when creating the mock server.

        when.method(GET)
            .path("/")
            .header_exists("x-amzn-lambda-context");

Done, thanks.

@bnusunny bnusunny merged commit 14ce8e1 into aws:main Jul 3, 2023
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 this pull request may close these issues.

2 participants