Http API Gateway with lambda integration for multiple routes


Customer uses Express (specifically using aws-serverless-express) with Lambda and HTTP API Gateway. The Lambda function handles several routes and Express is handling the internal routing according to the path.

Is it possible in HTTP API Gateway to add the base URL and let the Lambda route based on the path?

1 Answer
Accepted Answer

HTTP API contains a $default route that will be used when no other route matches the request. You can create a single integration and map it to the $default route. You can use specific methods or you can use the ANY method. See more here.

You can also use greedy path variables as described here. This will let you have several functions each handling a different part of the API (if needed), e.g., /users/{proxy+} will be routed to a function handling users, and /pets/{proxy+} to a function handling pets.

profile picture
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions