Skip to content

Fix APIGW path with stage #669

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
Jul 2, 2023
Merged

Fix APIGW path with stage #669

merged 2 commits into from
Jul 2, 2023

Conversation

calavera
Copy link
Contributor

@calavera calavera commented Jun 29, 2023

Issue #, if available:

Fixes #668

Description of changes:

APIGW HTTP has started adding the stage to the path in the event. This change checks if the stage is already a prefix in the path, and skips adding it if so.

This also introduces an environment variable to skip this behavior completely because there might be cases where the user just wants the runtime to do nothing.

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

calavera added 2 commits June 28, 2023 20:31
APIGW HTTP has started adding the stage to the path in the event. This change checks if the stage is already a prefix in the path, and skips adding it if so.

Signed-off-by: David Calavera <[email protected]>
There might be cases when you don't want the runtime to do anything with paths and stages. By setting AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH in the environment, we ignore this behavior completely.

Signed-off-by: David Calavera <[email protected]>
@calavera calavera force-pushed the fix_path_with_stage branch 3 times, most recently from 94a681e to 3127592 Compare June 29, 2023 03:59
@calavera calavera requested a review from bnusunny June 29, 2023 14:33
None => path.into(),
Some(stage) if stage == "$default" => path.into(),
Some(stage) => format!("/{stage}{path}"),
if env::var("AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH").is_ok() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be documented somewhere? Although looking through the docs I couldn't find an obvious home.

Otherwise LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's exactly why I didn't write any docs about it 😅

In theory, nobody should use this option, but who knows. The only case I could find for something like this is if your stage has a name, for example Prod, and you decide that the real path for your api also starts with /Prod. I've never seen something like this, but you never know.

@calavera calavera merged commit 6ca8a36 into main Jul 2, 2023
@calavera calavera deleted the fix_path_with_stage branch July 2, 2023 15:40
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.

Request path includes API gateway stage twice
3 participants