Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

c# - How can I aggregate requests in Ocelot API Gateway?

I have the following 2 endpoints: Localhost:5001/api/packages?storeid={id} Localhost:5002/api/stores/{id}

How can I aggregate them using Ocelot API Gateway?

i currently have this:

    {
      "RouteKeys": [
        "Business",
        "Packages"
      ],
      "UpstreamPathTemplate": "/test"
    }
  ],

But I don't know how it works when having 1 endpoint use the '/{id}' and the other having '?store={id}'

Below is my full Ocelot config:

  //Routing
  "Routes": [
    //Packages API with downroute
    {
      "DownstreamPathTemplate": "/api/Packages/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": "5001"
        }
      ],
      "UpstreamPathTemplate": "/api/Packages/{everything}",
      "Key": "PackagesDownroute"
    },
    //Packages API
    {
      "DownstreamPathTemplate": "/api/Packages",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": "5001"
        }
      ],
      "UpstreamPathTemplate": "/api/Packages",
      "Key": "Packages"
    },
    //Orders API
    {
      "DownstreamPathTemplate": "/api/Orders/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": "5002"
        }
      ],
      "UpstreamPathTemplate": "/api/Orders/{everything}"

    },

    //Business API with downroute
    {
      "DownstreamPathTemplate": "/api/Business/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": "5003"
        }
      ],
      "UpstreamPathTemplate": "/api/Business/{everything}",
      "Key": "BusinessDownroute"
    },
    //Business API
    {
      "DownstreamPathTemplate": "/api/Business",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": "5003"
        }
      ],
      "UpstreamPathTemplate": "/api/Business",
      "Key": "Business"

    }
  ],
  "Aggregates": [
    {
      "RouteKeys": [
        "BusinessDownroute",
        "Packages"
      ],
      "UpstreamPathTemplate": "/test"
    }
  ],
  //GLOBAL CONFIG
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:4999"
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...