-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support format version 2 for HTTP API's #124
Comments
Manually changing the payload to version 1 fixes the problem, do not know how to set that up with Ansible. |
@jmfederico do you mean you swap "version" in the incoming event? That seems dangerous as there have been changes, and apgi-wsgi thus won't parse all the request data. |
@adamchainz I mean changing the version that is sent to the Lambda function from the HttpAPI. It by default now uses version 2. One has to manually set the API to send the event usi no version 1. I do not use Ansible so I am not sure with the setup that you have which version it sends by default, but my guess is it sends version 2. It should be possible to use Ansible to ser the version to 1. |
Right, that can be changed in CloudFormation - docs . We don't have a But I don't care about fixing the example app. |
You don't need to add a
|
Check the event version before building the environment. Use the unpack operator to copy the original event to the v1 event object. Map missing keys needed by the environment builder from the v2 object. Values like request_context are passed unchanged. The multivalue headers and query string parameters are mapped back into strings then split back up into their original formats. It's inefficient and could be improved but ultimately leaves with unchanged logic for parsing the an identical end result.
Thanks for writing this library. I've been using it on some lambdas and recently needed to switch to v2 to use the JWT authorizer. I think I can switch back to the v1 version, as suggested, but I'd really prefer to write less configuration if possible :). I think I added this functionality in #174 . I'm using this myself and would love to roll it back into your project so I can go back to including this from pypi. Let me know if you have any feedback or changes. Thanks again! |
Use the latest versions of Python and dependencies, and use the v2 format for the HTTP API, for #124.
Use the latest versions of Python and dependencies, and use the v2 format for the HTTP API, for #124.
Check the event version before building the environment. Use the unpack operator to copy the original event to the v1 event object. Map missing keys needed by the environment builder from the v2 object. Values like request_context are passed unchanged. The multivalue headers and query string parameters are mapped back into strings then split back up into their original formats. It's inefficient and could be improved but ultimately leaves with unchanged logic for parsing the an identical end result.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Extended the example to deploy an HTTP API and dump its event, got one like this, plus error from trying to parse format version 1:
The text was updated successfully, but these errors were encountered: