I ran into an issue when using a route with the rule "/" along with strip_prefixes feature. This rule is unable to trigger due to the path variable being reduced down to an empty string instead of a forward slash.
from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
app = ApiGatewayResolver(strip_prefixes=["/some-path"])
@app.get('/')
def my_func():
return {'execution_status':'success'}
Expected Behavior
Accessing domain.com/some-path would execute my_func().
Current Behavior
Accessing domain.com/some-path returns a 404. Of note though, accessing domain.com/some-path/ (note the trailing slash) will execute my_func().
Possible Solution
Add an conditional here which will map an empty string to "/".
Steps to Reproduce (for bugs)
- Set up the code example above
- Set up ApiGateway to use a custom domain, and bind the Lambda to a custom path of
some-path
- Visit
https://CUSTOMDOMAIN/some-path and https://CUSTOMDOMAIN/some-path/ and note the different results
I ran into an issue when using a route with the rule
"/"along withstrip_prefixesfeature. This rule is unable to trigger due to thepathvariable being reduced down to an empty string instead of a forward slash.Expected Behavior
Accessing
domain.com/some-pathwould executemy_func().Current Behavior
Accessing
domain.com/some-pathreturns a 404. Of note though, accessingdomain.com/some-path/(note the trailing slash) will executemy_func().Possible Solution
Add an conditional here which will map an empty string to
"/".Steps to Reproduce (for bugs)
some-pathhttps://CUSTOMDOMAIN/some-pathandhttps://CUSTOMDOMAIN/some-path/and note the different results