Browse Source

调整

develop
H Vs 6 months ago
parent
commit
7be84755b0
1 changed files with 20 additions and 6 deletions
  1. +20
    -6
      TelpoKafkaConsole.WebApi/Program.cs

+ 20
- 6
TelpoKafkaConsole.WebApi/Program.cs View File

@@ -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>();


Loading…
Cancel
Save