-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartup.cs
49 lines (41 loc) · 1.44 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
namespace MicroMarketBackend.APIGateway
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
private IConfiguration Configuration { get; }
private const string ApiGatewayName = "MicroMarketApiGateway";
private const string ApiGatewayVersion = "v1";
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot();
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc(ApiGatewayVersion, new OpenApiInfo { Title = ApiGatewayName, Version = ApiGatewayVersion });
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint($"/swagger/{ApiGatewayVersion}/swagger.json", $"{ApiGatewayName} {ApiGatewayVersion}"));
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseOcelot().Wait();
}
}
}