Ocelot网关重复查询参数



我正在使用ocelot网关。

以下是配置的示例

{
"DownstreamPathTemplate": "/ipgeo?apiKey={key}&ip={ip}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "api.ipgeolocation.io",
"Port": 80
}
],
"UpstreamHttpMethod": ["GET"],
"UpstreamPathTemplate": "/GLI/secondary?apiKey={key}&ip={ip}"
}

正如您所看到的,有两个查询参数。当我使用邮递员发送请求时:

http://localhost:5000/GLI/secondary?apiKey=aaa&ip=8.8.8.8

OCELOT获取重复的查询参数并生成如下的下游url:

http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8

控制台屏幕:

info: Ocelot.Requester.Middleware.HttpRequesterMiddleware[0]
requestId: 0HMFNFVDSDQH9:0000000A, previousRequestId: no previous request id, message: 301 (Moved Permanently) status code, request uri: http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8

我该如何更改?

同样的问题,

对于我的作品使用这种语法,基本上我已经去掉了"quot;UpstreamPathTemplate:中的符号

"DownstreamPathTemplate": "/GLI/secondary?{everything}"
"UpstreamPathTemplate": "/GLI/secondary{everything}"

您可以使用

"DownstreamPathTemplate": "/ipgeo?{everything}"
"UpstreamPathTemplate": "/GLI/secondary?{everything}"

"UpstreamPathTemplate": "/GLI/secondary/{everything}"

相关内容

  • 没有找到相关文章

最新更新