• 01 .NET CORE 2.2 使用OCELOT -- 简单使用


      目前参考两篇文章,已实现基本的ocelot的网关功能。

      https://www.cnblogs.com/xlxr45/p/11320988.html

      https://www.jianshu.com/p/c967eda8b04d

      按照第一篇的操作,ocelot的网关宿主为cmd,因为本想用webapi项目引用ocelot实现网关功能,配置文件有点出入。

      后来搜索查到第二篇。简单修改下配置,configuration.json 如下

    {
      "ReRoutes": [
        {
          "DownstreamPathTemplate": "/api/customers",
          "DownstreamScheme": "http",
          "DownstreamHostAndPorts": [
            {
              "Host": "localhost",
              "Port": 9001
            }
          ],
          "UpstreamPathTemplate": "/customers",
          "UpstreamHttpMethod": [ "Get" ]
        },
        {
          "DownstreamPathTemplate": "/api/customers/{id}",
          "DownstreamScheme": "http",
          "DownstreamHostAndPorts": [
            {
              "Host": "localhost",
              "Port": 9001
            }
          ],
          "UpstreamPathTemplate": "/customers/{id}",
          "UpstreamHttpMethod": [ "Get" ]
        },
        {
          "DownstreamPathTemplate": "/api/products",
          "DownstreamScheme": "http",
          "DownstreamHostAndPorts": [
            {
              "Host": "localhost",
              "Port": 9002
            }
          ],
          "UpstreamPathTemplate": "/api/products",
          "UpstreamHttpMethod": [ "Get" ]
        }
      ]
    }

      修改三个项目的启动宿主为iisexpress、端口等,并在解决方案中设置为多项目启动。

      VS按F5启动,可以看到同时启动三个项目

  • 相关阅读:
    poj2352树状数组
    hdu1166树状数组
    poj2785双向搜索
    poj2566尺取变形
    poj2100还是尺取
    poj3061尺取法
    poj3320尺取法
    hdu3829最大独立集
    poj2594最小顶点覆盖+传递闭包
    经典换根dp——hdu2196
  • 原文地址:https://www.cnblogs.com/zhanglinfeng715/p/11692824.html
Copyright © 2020-2023  润新知