In API Gateway configuration, typically one specifies an complete API Path, such as /api/v1/fruits/list
. Sometimes, it may be necessary to specify a wildcard path that includes multiple complete API paths. This is how you can do it.
- Use curly brackets. Specify
/api/v1/fruits/{action}
to allow any action to be accepted. Action can be any valid URL path segment, but it only covers one depth. It does not cover deeper URL likeapi/v1/fruits/list/all
. - To cover all sub-links, use
{proxy+}
. The+
sign tells API Gateway to accept all sub-links. - Note that you need a separate API for the root path itself, in this case
/api/v1/fruits
needs its own API. It’s possible to use /api/v1/fruits/{action?} to cover the root path. Needs to be verified since it’s not in the documentation. - In GoLang, the wildcard value is passed to the Lambda handler in a string-to-string map named PathParameters.
PathParameters:map[string]string{"id":"234"}
See more at https://aws.amazon.com/blogs/aws/api-gateway-update-new-features-simplify-api-development/
No comments:
Post a Comment