Skip to content

fix(event-handler): pass event, context and request objects into handler #4329

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

Merged
merged 2 commits into from
Aug 14, 2025

Conversation

svozza
Copy link
Contributor

@svozza svozza commented Aug 14, 2025

Summary

This begins the work for for repsonse handling piece of the REST API event handler. As with other event handlers we need to pass the raw event and the lambda context as option into the handler. We will also pass a Request object in, should users prefer to use this web standard when defining their handlers.

Changes

  • Updated the type definition of RouteHandler and ErrorHandler to support passing the new parameters in.
  • Tightened the return type of RouteHandler from any to Response | JSONObject
  • Updated the unit tests to reflect these new changes
  • Added factory function to unit tests for creating events of type APIGatewayProxyEvent
  • Removed trace and connect HTTP methods [see note]

Note

When attempting to create a Request object for the trace and connect tests, I received an error from the constructor saying they were not supported. On investigation I discovered that these methods are forbidden by the Fetch specification due to security concerns. I do not think we should support these methods in the event handler so have removed them.

Issue number: closes #4340


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

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@svozza svozza self-assigned this Aug 14, 2025
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Aug 14, 2025
@svozza svozza added this to the Event Handler Beta (priority) milestone Aug 14, 2025
@boring-cyborg boring-cyborg bot added event-handler This item relates to the Event Handler Utility tests PRs that add or change tests labels Aug 14, 2025
@svozza svozza requested a review from dreamorosi August 14, 2025 07:33
@svozza svozza changed the title fix(event-handler): pass event, context and request objects into hand… fix(event-handler): pass event, context and request objects into handler Aug 14, 2025
@svozza svozza force-pushed the event-handler/request-event-context branch from 491fe9f to a6df09c Compare August 14, 2025 11:07
Copy link

@dreamorosi dreamorosi self-requested a review August 14, 2025 14:00
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@svozza svozza merged commit ea0e615 into main Aug 14, 2025
34 checks passed
@svozza svozza deleted the event-handler/request-event-context branch August 14, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-handler This item relates to the Event Handler Utility size/L PRs between 100-499 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: pass event, context and request objects into handler
2 participants