Ocelot使用案例,结合IdentityServer4进行鉴权,结合Consul进行服务治理
/*服务治理第三方组件Consul相关配置参数*/
"ServiceDiscovery": {
"ServiceName": "ApiOne", //本WebApi项目的服务名称,可以随便取名,将显示Consul的管理页面上,届时通过该服务名查找可用的服务站点
"Consul": {
"HttpEndpoint": "http://127.0.0.1:8500",
"TcpEndpoint": {
"Address": "127.0.0.1",
"Port": 8600
}
}
}
"AuthenticationOptions": {
"AuthenticationProviderKey": "TestKey",
"AllowedScopes": []
}
dotnet run —ip 127.0.0.1 —port 8000
dotnet run —ip 127.0.0.1 —port 8001
这样就启动了ApiOne项目的两个实例,能接受ip和port参数是因为自己写的代码才支持这样运行,同理可以允许多个ApiTwo项目的实例