|
|
@@ -1,4 +1,5 @@ |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.OpenApi.Models; |
|
|
|
using Serilog; |
|
|
|
using TelpoKafkaConsole.Model; |
|
|
|
using TelpoKafkaConsole.Service; |
|
|
@@ -47,15 +48,28 @@ namespace TelpoKafkaConsole.WebApi |
|
|
|
var app = builder.Build(); |
|
|
|
|
|
|
|
// Configure the HTTP request pipeline. |
|
|
|
//if (app.Environment.IsDevelopment()) |
|
|
|
//{ |
|
|
|
// app.UseSwagger(); |
|
|
|
// app.UseSwaggerUI(); |
|
|
|
//} |
|
|
|
if (app.Environment.IsDevelopment()) |
|
|
|
{ |
|
|
|
app.UseSwagger(); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var prefix = "kafkaconsole"; |
|
|
|
app.UseSwagger(c => |
|
|
|
{ |
|
|
|
c.PreSerializeFilters.Add((swagger, httpReq) => |
|
|
|
{ |
|
|
|
var scheme = httpReq.Headers.TryGetValue("X-Forwarded-Proto", out var v2) ? v2.ToString() : httpReq.Scheme; |
|
|
|
swagger.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"{scheme}://{httpReq.Host}/{prefix}" } }; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
app.UseSwagger(); |
|
|
|
app.UseSwaggerUI(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization(); |
|
|
|
|
|
|
|
app.UseMiddleware<LoggingMiddleware>(); |
|
|
|