Skip to content

Feature request: Better strip-prefixes for APIGatewayRestResolver  #2494

Closed
@royassis

Description

@royassis

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions