01 .NET CORE 2.2 使用OCELOT -- 简单使用
2024-09-17 13:30:07
目前参考两篇文章,已实现基本的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":
}
],
"UpstreamPathTemplate": "/customers",
"UpstreamHttpMethod": [ "Get" ]
},
{
"DownstreamPathTemplate": "/api/customers/{id}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port":
}
],
"UpstreamPathTemplate": "/customers/{id}",
"UpstreamHttpMethod": [ "Get" ]
},
{
"DownstreamPathTemplate": "/api/products",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port":
}
],
"UpstreamPathTemplate": "/api/products",
"UpstreamHttpMethod": [ "Get" ]
}
]
}
修改三个项目的启动宿主为iisexpress、端口等,并在解决方案中设置为多项目启动。
VS按F5启动,可以看到同时启动三个项目
最新文章
- LeetCode之104. Maximum Depth of Binary Tree
- SpringMVC+Mybatis+Spring整合
- LNMP 环境发布项目
- centos6.5\win7双系统安装配置
- DSPLIB for C6455+CCSv3.3
- Linux设备驱动中的异步通知与异步I/O
- MySQL源码 数据结构hash
- iOS学习笔记(十四)——打电话、发短信
- 从JVM字节码执行看重载和重写
- LindDotNetCore~Polly组件对微服务场景的价值
- 拿到6个重磅offer的大神,超详细面试经验总结
- access denied for user 'root'@'localhost'(using password:YES) FOR WINDOWS
- 掌上电脑设备可以使用Ubuntu MATE 18.10 Linux映像了
- 7个Java项目,或许你的大学老师就会布置
- keras中的loss、optimizer、metrics
- Swift 内存管理
- 简单分页查询(web基础学习笔记十三)
- Problem G: 沉迷字符的WJJ (LCS)
- SQL注入(SQL Injection)案例和防御方案
- andriod 下一个页面