如何让API网关将路径转发到下游应用程序? [英] How can I let API gateway forward the path to down stream application?

查看:53
本文介绍了如何让API网关将路径转发到下游应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS中构建了一个API网关,并使用/{proxy +} 将路径/下的所有请求转发到下游ALB(ALB_ENDPOINT).但是我发现API网关在转发过程中不保留路径.例如,如果用户将 APIGATEAY_ENDPOINT/abc 重新设置为API网关,则会将其转发到 ALB_ENDPOINT/,而不是 ALB_ENDPOINT/abc .看来API网关已从端点删除了路径.

当API网关将其转发到下游应用程序时,如何使该路径持久化?

解决方案

如果我们这样定义/{proxy +}:

proxy 将是请求的路径参数,并且只需在url末尾添加/{proxy}并从方法映射该代理即可将整个路径附加到集成端点.request.path.proxy

我们需要在端点网址的末尾添加/{proxy}

I build an API gateway in AWS and use /{proxy+} to forward all requests under the path / to my down stream ALB (ALB_ENDPOINT). But I found API gateway doesn't keep the path during forwarding. For example, if users requset APIGATEAY_ENDPOINT/abc to API gateway, it will forward it to ALB_ENDPOINT/ instead of ALB_ENDPOINT/abc. It seems API gateway removes the path from the endpoint.

How can I make API gateway persists the path when it forwards it to downstream application?

解决方案

If we define a /{proxy+} like this:

proxy will be the path parameter of the request and entire path can be appended to integration endpoint by simply adding /{proxy} at the end of the url and mapping that proxy from method.request.path.proxy

We need to add /{proxy} at the end of the endpoint url

Here is the tutorial for HTTP Api

这篇关于如何让API网关将路径转发到下游应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆