首页 > 解决方案 > Ocelot API Gateway 可选参数

问题描述

有没有办法告诉 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-coreapi-gatewayocelot

解决方案


你可以使用{everything}喜欢

"DownstreamPathTemplate": "/api/SearchAPI/{everything}"

推荐阅读