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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则