Skip to content

Feature request: Better strip-prefixes for APIGatewayRestResolver #2494

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

Closed
2 tasks done
royassis opened this issue Jun 17, 2023 · 4 comments · Fixed by #2521
Closed
2 tasks done

Feature request: Better strip-prefixes for APIGatewayRestResolver #2494

royassis opened this issue Jun 17, 2023 · 4 comments · Fixed by #2521
Assignees
Labels

Comments

@royassis
Copy link
Contributor

royassis commented Jun 17, 2023

Use case

I have multiple API Gateway Rest apis backed by AWS Lambda.
I want to these APIs to the same Custom domain name with different paths.

For example I have APIs with these urls, each backed by a different lambda:

  1. https://xxx.execute-api.us-east-1.amazonaws.com/v1
  2. https://yyy.execute-api.us-east-1.amazonaws.com/v1
  3. https://xxx_test.execute-api.us-east-1.amazonaws.com/v1
  4. https://yyy_test.execute-api.us-east-1.amazonaws.com/v1

I want both of them to be available from:

  1. https://mydomain.com/api/v1/xxx
  2. https://mydomain.com/api/v1/yyy
  3. https://mydomain.com/api/test/xxx
  4. https://mydomain.com/api/test/yyy
    respectively.

When Init-ing the APIGatewayRestResolver class I would have to pass in the strip_prefixes.

strip_prefixes=["/api/v1/xxx", "/api/test/xxx"]

We could potentials go to a high level of options due to combinatorics.

Solution/User Experience

  1. Use regex:
strip_prefixes=["^.*?xxx"]
  1. The path will be stripped of the prefixes one by one from left to right.
strip_prefixes=["api", "v1" ,"test","xxx"]

So if out initial path is /api/v1/xxx it will strip "api" first:
/api/v1/xxx -> /v1/xxx
Then v1
/v1/xxx -> /xxx
Then it will try to strip "test" but nothing would change:
/xxx - > /xxx
Then it will strip "xxx"
/xxx - > /

Alternative solutions

No response

Acknowledgment

@leandrodamascena
Copy link
Contributor

Hi @royassis! Thanks for opening this issue and bringing up your use case. Do you have bandwidth to send a PR to add regex support for this field?

@leandrodamascena leandrodamascena removed the triage Pending triage from maintainers label Jun 19, 2023
@leandrodamascena leandrodamascena moved this from Triage to Pending customer in Powertools for AWS Lambda (Python) Jun 20, 2023
@royassis
Copy link
Contributor Author

@leandrodamascena #2521

@rubenfonseca
Copy link
Contributor

Looking at this now

@rubenfonseca rubenfonseca moved this from Working on it to Pending customer in Powertools for AWS Lambda (Python) Jun 30, 2023
@heitorlessa heitorlessa moved this from Pending customer to On hold in Powertools for AWS Lambda (Python) Jul 10, 2023
@heitorlessa heitorlessa moved this from On hold to Pending customer in Powertools for AWS Lambda (Python) Aug 1, 2023
@github-project-automation github-project-automation bot moved this from Pending customer to Coming soon in Powertools for AWS Lambda (Python) Aug 14, 2023
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Shipped
Development

Successfully merging a pull request may close this issue.

3 participants