Skip to content

Commit

Permalink
fix: add Bind for kestrel config
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Feb 8, 2024
1 parent f8535f7 commit 0661dbe
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/GZCTF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@

builder.WebHost.ConfigureKestrel(options =>
{
options.Configure(builder.Configuration.GetSection("Kestrel"));
var kestrelSection = builder.Configuration.GetSection("Kestrel");
options.Configure(kestrelSection);
kestrelSection.Bind(options);
});

builder.Logging.ClearProviders();
Expand Down Expand Up @@ -131,14 +133,10 @@

#endregion OpenApiDocument

#region SignalR
#region SignalR & Cache

ISignalRServerBuilder signalrBuilder = builder.Services.AddSignalR().AddJsonProtocol();

#endregion SignalR

#region Cache

var redisConStr = builder.Configuration.GetConnectionString("RedisCache");
if (string.IsNullOrWhiteSpace(redisConStr))
{
Expand All @@ -157,7 +155,7 @@
});
}

#endregion Cache
#endregion SignalR & Cache

#region Identity

Expand Down Expand Up @@ -243,8 +241,6 @@
builder.Services.AddHostedService<FlagChecker>();
builder.Services.AddHostedService<CronJobService>();

#endregion Services and Repositories

builder.Services.AddHealthChecks();
builder.Services.AddRateLimiter(RateLimiter.ConfigureRateLimiter);
builder.Services.AddResponseCompression(options =>
Expand All @@ -261,14 +257,18 @@
options.InvalidModelStateResponseFactory = GZCTF.Program.InvalidModelStateHandler;
});

WebApplication app = builder.Build();
#endregion Services and Repositories

app.UseRequestLocalization();
#region Middlewares

WebApplication app = builder.Build();

Log.Logger = LogHelper.GetLogger(app.Configuration, app.Services);

await app.RunPrelaunchWork();

app.UseRequestLocalization();

app.UseResponseCompression();

app.UseStaticFiles(new StaticFileOptions
Expand Down Expand Up @@ -315,6 +315,8 @@

app.MapFallbackToFile("index.html");

#endregion Middlewares

await using AsyncServiceScope scope = app.Services.CreateAsyncScope();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<GZCTF.Program>>();

Expand Down

0 comments on commit 0661dbe

Please sign in to comment.