首页 > 解决方案 > 如何根据 AWS API Gateway 中的请求标头动态设置集成端点?

问题描述

我想根据请求中收到的请求标头将传入请求代理到不同的端点。

在 AWS API 网关中,我可以将不同的端点设置为单独的阶段变量,但在集成 >> 端点 URL 设置中,我想根据请求标头值的值选择阶段变量。

例如:

如果标头值为 brand-id: abc 那么请求应该被代理到 abc.test.com

如果标头值为 brand-id: pqr 那么请求应该被代理到 pqr.test.com

我在“端点 URL”值中期待这样的东西: http://${stageVariables.${method.request.header.brand-id}}/

任何帮助实现这一点将不胜感激。

标签: amazon-web-servicesaws-api-gatewayapi-gatewayamazon-api-gateway

解决方案


AFAIK this is not possible on the API Gateway level. Option is to do the mapping on the lambda integration level.


推荐阅读