Files
jinko.yikatong/Src/Gateway/Startup.cs
2024-03-14 19:29:30 +08:00

42 lines
1.0 KiB
C#

using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
namespace Gateway;
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "# gateway api..." });
});
services.AddOcelot();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
var services = Configuration.GetSection("Services").Get<List<string>>();
foreach (var s in services)
{
c.SwaggerEndpoint($"/{s.ToLower()}/swagger/v1/swagger.json", s);
}
});
app.UseOcelot().Wait();
}
}