Ocelot API网关可选参数

问题描述 投票:2回答:1

是否可以告诉Ocelot参数是可选的?

假设下面的查询参数是可选的:

"DownstreamPathTemplate": "/api/SearchAPI/?query={query}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
    {
        "Host": "localhost",
        "Port": 5000
    }
],
"UpstreamPathTemplate": "/api/SearchAPI/?query={query}",
"UpstreamHttpMethod": [ "GET" ],
"FileCacheOptions": {
    "TtlSeconds": 60
}

如果我向/SearchAPI/?query=发送请求,则会收到404作为响应。我需要复制Upstream以不使用参数进行修复。还有另一种解决方法吗?

asp.net-core api-gateway ocelot
1个回答
0
投票

您可以像使用{everything}

"DownstreamPathTemplate": "/api/SearchAPI/{everything}"
© www.soinside.com 2019 - 2024. All rights reserved.