温馨提示:本文翻译自stackoverflow.com,查看原文请点击:asp.net core - Ocelot API Gateway Optional Parameter
asp.net-core ocelot api-gateway

asp.net core - Ocelot API Gateway可选参数

发布于 2020-03-29 12:58:10

有没有办法告诉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,以免使用参数进行修复。还有另一种解决方法吗?

查看更多

查看更多

提问者
Israel Rodriguez
被浏览
18
Roman Marusyk 2020-01-31 16:56

您可以使用{everything}

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