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 for HttpApi $default route, $default stage and 2.0 payloads #1175
Conversation
LOL, @apancutt, I was just about to patch the path params for Few quick questions:
Do you have time to add tests those three route scenarios? They are probably:
@frozenbonito / @dherault would you put those path tests under I'm guessing Cheers, |
@apancutt Just a BREAKING CHANGE note for your PR - specifically the change:
This changes the previous behaviour of inserting the serverless stage into the url when using it in offline mode. This affects all This will break any integration tests that use Essentially current I'm just starting to work through the PR in an active project, so I'll report any other findings as they come up. Bryan |
Hi there -- I started using this PR because we need v2 payloads in order to use serverless-offline. I just wanted to point out one notable difference between using this package and the real API Gateway. It seems the API Gateway always makes incoming HTTP header names lower-cased, but I don't know if that's an issue that needs to be addressed with this PR (is this a specific trait of the v2 gateway requests?), or if this is a larger issue with this package. I'd be happy to help wherever I can with this PR, though, we need it! 😄 Thanks! |
I've just reported this issue independently as #1207 |
…e info is now available in routeKey
Is there anything that prevent this from getting merged? |
@nponeccop there is nothing preventing this from from getting merged. Currently using this for production development and it's a bit awkward referencing a PR branch... Cheers, |
Hello @bryanvaz - I'm just getting up to speed with the project so I don't feel confident yet in fully assessing the change - you mentioned a breaking change in one of the previous comments - could you explain a bit more? Is that breaking change necessary? |
@pgrzesik the breaking change is that the stage name is never prepended to the URL. This is because Serverless will always deploy to the It's possible that many/most users will already be disabling the stage prefix using the |
In fact, all of the changes could be considered breaking given the right set of circumstances, except for the last one on the list above. Possibly warrants a major version bump. |
Exactly, it's less a breaking change in the sense that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bryanvaz for detailed explanation 🙇 I believe we're safe to merge this PR and it will be a good idea to release it as a part of next major release to avoid potentially breaking local workflows, even though it's actually fixing the behavior of httpApi
. 👍
Hello @apancutt - it looks like unfortunatelly, there was a slight regression introduced with this PR which causes one CORS-related tests to fail, do you think you'd be able to take a look at it? Example: https://github.com/dherault/serverless-offline/runs/2391560450?check_suite_focus=true |
Description
Fixes #1118 but also addresses other issues found with
httpApi
events:2.0
(NB: also implemented by Default httpApi payload to 2.0 #1126 which does not include required fixes to 2.0 event payloads)$default
route$default
stage (Serverless always deploys to$default
stage which should never be prepended to URL)Support for CORS configuration which is provided in(reverted in favor of Add support for HttpApi cors configuration #1153)provider.httpApi
LambdaProxyIntegrationEvent.resource
which should be the route key (forhttpApi
events only)LambdaProxyIntegrationEventV2.routeKey
which should be the route keyLambdaProxyIntegrationEventV2.rawPath
which should be obtained from the requested URL (not the route)LambdaProxyIntegrationEventV2.rawQueryString
andLambdaProxyIntegrationEventV2.queryStringParameters
to use existingURL
instance provided in#request
.Motivation and Context
It is currently not possible to define
$default
routes forhttpApi
events. The current workaround requires inconsistent implementation between Serverless Offline and AWS (using a{proxy+}
hack locally).The default event payload should reflect the default payload provisioned by Serverless/AWS.
The 2.0 payload format is currently wrong.
How Has This Been Tested?
Compared event payloads (1.0 and 2.0) received on AWS against those received via Serverless Offline for both
$default
route and named routes.Tested locally - payloads 1.0 and 2.0 are both handled successfully for named routes and
$default
route (defined inserverless.yml
as{ httpApi: '*' }
).Updated related tests by removing stage prefix which is not used by Serverless (it unconditionally uses the
$default
stage).