簡體   English   中英

ASP.NET 核心網關 ocelot API 不工作

[英]ASP.NET Core gateway ocelot API doesn't work

我正在使用微服務創建一個項目,現在我希望能夠測試我使用 ocelot 作為編排器創建的 API 網關,但是我無法通過瀏覽器對其進行測試,API 無法訪問它,有人可以嗎幫助?

ocelot.json:

{
  "Routes": [
    // Billing.API
    {
      "DownstreamPathTemplate": "/api/v1/Billing",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "billingapi",
          "Port": "80"
        }
      ],
      "UpstreamPathTemplate": "/Billing",
      "UpstreamHttpMethod": [ "GET" ]
    }
  ]
}

當我運行項目並在瀏覽器中 URL 我通過/api/v1/Billing

當我通過DownstreamPathTemplate屬性。 什么都沒有歸還給我。

我建議先嘗試通用模板,看看它是否有效:

{
    "DownstreamPathTemplate": "/{everything}",
    "DownstreamScheme": "http",
    "DownstreamHostAndPorts": [
            {
                "Host": "billingapi",
                "Port": 80,
            }
        ],
    "UpstreamPathTemplate": "/billingapi/{everything}",
    "UpstreamHttpMethod": [ "Get", "Post" ]
}

來自關於下游的 Ocelot 文檔:

The DownstreamPathTemplate, DownstreamScheme and DownstreamHostAndPorts define the URL that a request will be forwarded to.

對於上游:

The UpstreamPathTemplate is the URL that Ocelot will use to identify which DownstreamPathTemplate to use for a given request. 

您應該在瀏覽器上傳遞 UpstreamPathTemplate URL 以路由計費 API。 在您的情況下,請求HTTP://<gateway.address>/Billings將被路由到HTTP://billingapi/api/v1/Billing

暫無
暫無

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

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