簡體   English   中英

Ocelot API 網關可選參數

[英]Ocelot API Gateway Optional Parameter

有沒有辦法告訴 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}"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM