目前參考兩篇文章,已實現基本的ocelot的網關功能。 https://www.cnblogs.com/xlxr45/p/11320988.html https://www.jianshu.com/p/c967eda8b04d 按照第一篇的操作,ocelot的網關宿主為cmd,因為本想用webapi ...
目前參考兩篇文章,已實現基本的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啟動,可以看到同時啟動三個項目