AWS API Gateway - URL rewrite

0

My requirement is to rewrite url in API Gateway (REST API) . API Gateway (+ Lambda authorizer) --> VPC Link --> NLB--> (internal) ALB --> ECS For e.g. if my external facing url is "bookings/trains/7010" it needs to be rewritten as "bookings/clients/123/trains/7010" when calling backend url where I extract clients data from the encrypted token (during auth token validation) in Lambda authorizer. Is there way to do it in gateway?

VJ
已提問 1 年前檢視次數 1991 次
1 個回答
1
已接受的答案

For an API Gateway operation like this:

/bookings/trains/{trainID}

Calling a backend API like this:

/bookings/clients/{clientID}/trains/{trainID}

The trainID Path Parameter, "7010", will map straight across to the Endpoint URL defined in your API Integration Request.

To get the clientID from your Lambda Custom Authorizer, you would need to make sure the authorizer returns the following context map:

"context" : {
  "clientID": "123"
}

Then implement a Request Mapping Template with the following line of code:

#set($context.requestOverride.path.clientID = $context.authorizer.clientID)
profile picture
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南