Swagger 昂首阔步加奥克洛特
我正在尝试用ocelot和swagger()实现网关。我能够在本地主机中很好地配置所有内容,现在我需要将我的解决方案部署到kubernetes,但是,因为有一些功能是并行开发的,所以我被要求将我的解决方案部署到一个子目录中,类似这样Swagger 昂首阔步加奥克洛特,swagger,ocelot,Swagger,Ocelot,我正在尝试用ocelot和swagger()实现网关。我能够在本地主机中很好地配置所有内容,现在我需要将我的解决方案部署到kubernetes,但是,因为有一些功能是并行开发的,所以我被要求将我的解决方案部署到一个子目录中,类似这样 https://domain/Feature1/gateway1 https://domain/Feature2/gateway2 他们不知道如何按功能划分子域 app.Use((context, next) => { context.Reque
- https://domain/Feature1/gateway1
- https://domain/Feature2/gateway2
app.Use((context, next) =>
{
context.Request.PathBase = new PathString("/apifeature1");
return next();
});
.
.
.
app.UseSwaggerForOcelotUI(c =>
{
c.DownstreamSwaggerEndPointBasePath = "/apifeature1/swagger/docs";
c.PathToSwaggerGenerator = "/apifeature1/swagger/docs";
c.DocumentTitle = "DOCUMENT";
});
我的配置可以工作,但swagger UI有一个问题,因为测试路径是这样映射的
https://domain/api/service/method
但我需要像这样的东西
https://domain/Feature1/api/service/method
可能吗?我不确定我是否能帮上忙,但MMLib.SwaggerForOcelot支持虚拟目录 也许这对某人有帮助,这是我唯一能让这个设置正常工作的方法 到达以下位置的招摇过市文档: https://domain/gatewayfeature1 以及以下的API: https://domain/apisfeature1 另一个特性也是如此 文件 https://domain/gatewayfeature2 原料药 https://domain/apisfeature2 我将nginx用作反向代理,ocelot用作和GKE集群中api的网关 我最后使用的入口yaml是这一特性,“apifeature1”、“apifeature2” Ocelot按功能“apifeature1”、“apifeature2”配置 在本例中,我从配置中读取特性名称,因此ocelot配置结束时与本例类似
{
"UpstreamPathTemplate": "/apifeature1/api/controller/{everything}",
"UpstreamHttpMethod": [ "Get", "Post" ],
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "apifeature1",
"Port": "80"
}
],
"SwaggerKey": "api"
},
和网关的功能
app.Use((context, next) =>
{
context.Request.PathBase = new PathString("/apifeature1");
return next();
});
.
.
.
app.UseSwaggerForOcelotUI(c =>
{
c.DownstreamSwaggerEndPointBasePath = "/apifeature1/swagger/docs";
c.PathToSwaggerGenerator = "/apifeature1/swagger/docs";
c.DocumentTitle = "DOCUMENT";
});
它可以工作,但我认为可以改进。HI Mino,更具体地说,API(下游)在根目录中运行,因此,我认为使用virtualdirectory不适用于这种情况。