react-lambda-example icon indicating copy to clipboard operation
react-lambda-example copied to clipboard

Aws Api gateway route

Open huhuhong opened this issue 7 years ago • 3 comments

Hi,

I would assume you expose lambda function via AWS API Gateway. May I know how many endpoint path you define in API gateway to route different static page like home, about and etc.

huhuhong avatar Mar 21 '18 12:03 huhuhong

It can be just a single API Gateway endpoint, as all the request details are passed to the Lambda, so from there you are able to perform routing based on the path that was entered in the URL. And API Gateway can be configured to always pass all routes to the same Lambda function.

domderen avatar Mar 25 '18 18:03 domderen

Let's say I have route below /Home /Room/(id)

So I would need to define api gateway path:

  1. /home
  2. /Room/(path variable for id)

What if I add context route path: /Base/home /Base/room/(Id)

Can I just configure a single API gateway path which is /base to accept both route? I trying to avoid have to configure multiple API gateway path whenever I introduce new route.

huhuhong avatar Mar 27 '18 10:03 huhuhong

As far as I remember you can configure such paths in APIG:

  • /{variable1}
  • /{variable1}/{variable2}
  • /{variable1}/{variable2}/{variable3}

And point all of them to your Lambda. Next use variable1/2/3 to return a specific HTML for your path.

domderen avatar Apr 09 '18 04:04 domderen