当前位置: 首页 > news >正文

百度收录左侧带图片的网站四川清风建设工程有限公司网站

百度收录左侧带图片的网站,四川清风建设工程有限公司网站,做渔船的网站,可做笔记的阅读网站Ocelot是一个.net core框架下的网关的开源项目#xff0c;下图是官方给出的基础实现图#xff0c;即把后台的多个服务统一到网关处#xff0c;前端应用#xff1a;桌面端#xff0c;web端#xff0c;app端都只用访问网关即可。 Ocelot的实现原理就是把客户端对网关的请求… Ocelot是一个.net core框架下的网关的开源项目下图是官方给出的基础实现图即把后台的多个服务统一到网关处前端应用桌面端web端app端都只用访问网关即可。   Ocelot的实现原理就是把客户端对网关的请求(Request)按照configuration.json的映射配置转发给对应的后端http service然后从后端http service获取响应(Response)后再返回给客户端。当然有了网关后我们可以在网关这层去做统一验证也可以在网关处统一作监控。 接下来做个Demo 新建三个asp.net core web aip项目 OcelotGateway网关项目端口是5000 DemoAAPI项目A端口是5001 DemoBAPI项目B端口是5002 (注端口可以在每个项目的Properties下的launchSettings.json中修改发布后的端口可以在Program.cs中用UseUrls(“http://*:5000”)来修改) 对于OcelotGateway 引用Ocelot的Nuget包 视图-其他窗口-程序包管理控制台Install-Package Ocelot 或项目右键“管理Nuget程序包”在浏览里查找Ocelot进行安装 在OcelotGateway项目中添加一个configuration.json文件关把它的属性“复制到输出目录”设成“始终复制”内容如下 {   ReRoutes: [     {       DownstreamPathTemplate: /demoaapi/values,       DownstreamScheme: http,       DownstreamPort: 5001,       DownstreamHost: localhost,       UpstreamPathTemplate: /demoaapi/values,       UpstreamHttpMethod: [ Get ],       QoSOptions: {         ExceptionsAllowedBeforeBreaking: 3,         DurationOfBreak: 10,         TimeoutValue: 5000       },       HttpHandlerOptions: {         AllowAutoRedirect: false,         UseCookieContainer: false       },       AuthenticationOptions: {         AuthenticationProviderKey: ,         AllowedScopes: []       }     },     {       DownstreamPathTemplate: /demobapi/values,       DownstreamScheme: http,       DownstreamPort: 5002,       DownstreamHost: localhost,       UpstreamPathTemplate: /demobapi/values,       UpstreamHttpMethod: [ Get ],       QoSOptions: {         ExceptionsAllowedBeforeBreaking: 3,         DurationOfBreak: 10,         TimeoutValue: 5000       },       HttpHandlerOptions: {         AllowAutoRedirect: false,         UseCookieContainer: false       },       AuthenticationOptions: {         AuthenticationProviderKey: ,         AllowedScopes: []       }     }   ] } 接下来对OcelotGateway的Program.cs进行改造  using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection;   namespace OcelotGateway {     public class Program     {         public static void Main(string[] args)         {             BuildWebHost(args).Run();         }         public static IWebHost BuildWebHost(string[] args)         {             IWebHostBuilder builder new WebHostBuilder();             //注入WebHostBuilder             return builder.ConfigureServices(service                 {                     service.AddSingleton(builder);                 })                 //加载configuration配置文人年                 .ConfigureAppConfiguration(conbuilder                 {                     conbuilder.AddJsonFile(configuration.json);                 })                 .UseKestrel()                 .UseUrls(http://*:5000)                 .UseStartupStartup()                 .Build();         }     } } 同时修改Startup.cs using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Ocelot.DependencyInjection; using Ocelot.Middleware;   namespace OcelotGateway {     public class Startup     {         public Startup(IConfiguration configuration)         {             Configuration configuration;         }         public IConfiguration Configuration { get; }              public void ConfigureServices(IServiceCollection services)         {                   //注入配置文件AddOcelot要求参数是IConfigurationRoot类型所以要作个转换             services.AddOcelot(Configuration as ConfigurationRoot);         }         public  void Configure(IApplicationBuilder app, IHostingEnvironment env)         {             //添加中间件             app.UseOcelot().Wait();         }     } } 为了测试数据好看我们把DemoAAPI项目和DemoBAPI项目的ValuesController作一下修改     [Route(demoaapi/[controller])]     public class ValuesController : Controller     {                [HttpGet]         public IEnumerablestring Get()         {             return new string[] { DemoA服务, 请求 };         } //…… }       [Route(demobapi/[controller])]     public class ValuesController : Controller     {                [HttpGet]         public IEnumerablestring Get()         {             return new string[] { DemoB服务, 请求 };         } //…… } 最后在解决方案属性-多个启动项目中把DemoAAPIDemoBAPIOcelotGateway都设成启动开始启动解决方案效果如下图  相关文章 Ocelot——初识基于.Net Core的API网关 Ocelot API网关的实现剖析 微服务网关Ocelot API网关Ocelot 使用Polly 处理部分失败问题 谈谈微服务中的 API 网关API Gateway 原文http://www.cnblogs.com/axzxs2001/p/8005041.html .NET社区新闻深度好文欢迎访问公众号文章汇总 http://www.csharpkit.com
http://www.pierceye.com/news/56717/

相关文章:

  • 建立网站需要什么手续网站迁移教程
  • 金华网站建设报价网页前端设计包括哪些内容
  • 做直播网站要多大带宽越秀做网站
  • wordpress建站不好用江西省住房和城乡建设厅网站首页
  • 最好的营销型网站建设公司南昌地宝网官网
  • 环球新军事最新消息seo站群优化技术
  • 聊城网站建设哪个好些网站建设需求说明文档
  • 网站服务器参数查询做网站带微好吗
  • 网站建设中...物流专线网站建设
  • 做网站设计图用什么软件韩国 网站设计
  • 古色古香 网站模板商业网站建设定位
  • 赣州做网站的公司哪家好莱芜 做网站 公司
  • 重庆川九建设有限责任公司官方网站兼职网站建设招聘信息
  • 平潭综合实验区交通与建设网站企业网站建设合同书标准版
  • 天水市建设路第二小学网站做外贸的推广渠道
  • 惠州做网站 百度优化想自己做网站吗
  • excel做网站二维码在线借贷网站建设
  • 启动wordpress怎样做网站seo优化
  • 大兴黄村网站建设公司浙江华企做的网站效果如何
  • 校内网站建设与维护怎么创造自己的公众号
  • 交钱做网站对方拿了钱不做该怎么办深圳网站建设 外包合作
  • asp网站开发设计文档网站设置快捷方式到桌面
  • 临沂企业建站程序关于建设网站的请示
  • 做任务免费得晋江币网站抖音代运营方案怎么写
  • 汕尾北京网站建设自建网站做淘宝联盟
  • 郑州做网站hnqfu赣州做网站找谁
  • 浙江平台网站建设制作制作一个手机app需要多少钱
  • 家私公司网站建设多少钱湖南手机响应式网站建设企业
  • 海口企业免费建站网站维护建设需要什么花费
  • 长春建设厅网站首页常平营销网站建设