有没有办法告诉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
,以免使用参数进行修复。还有另一种解决方法吗?
您可以使用{everything}
像
"DownstreamPathTemplate": "/api/SearchAPI/{everything}"