Skip to content

Commit

Permalink
Arrange middleware order
Browse files Browse the repository at this point in the history
  • Loading branch information
tranvuongduy2003 committed Oct 22, 2024
1 parent a4ac555 commit a8be447
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/EventHub.Presentation/Extensions/ApplicationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using EventHub.Infrastructure.Configurations;
using EventHub.Persistence.Data;
using EventHub.Presentation.Middlewares;
using EventHub.SignalR.Hubs;
using Microsoft.EntityFrameworkCore;
using Serilog;

@@ -12,21 +13,38 @@ public static void UseInfrastructure(this WebApplication app, string appCors)
{
app.UseSwaggerDocumentation();

// app.UseHttpsRedirection(); //production only

// 1, Exception Handler
app.UseMiddleware<ErrorWrappingMiddleware>();

// 2, HSTS

// 3, HttpsRedirection
// app.UseHttpsRedirection(); //production only

// 4, Static Files

// 5, Routing

// 6, CORS
app.UseCors(appCors);

// 7, Authentication
app.UseAuthentication();

// 8, Authorization
app.UseAuthorization();
app.UseCors(appCors);

// 9, Custom
app.UseHangfireBackgroundJobs();
app.UseHangfireDashboard(app.Configuration);
app.MapControllers();
app.MapGet("/", context => Task.Run(() =>
context.Response.Redirect("/swagger/index.html")));

// Hubs
// app.MapHub<ChatHub>("/Chat");

app.MapHub<ChatHub>("/Chat");

// 10, Endpoint
app.MapControllers();

// Auto migrating and seeding data
using var scope = app.Services.CreateScope();
{
var services = scope.ServiceProvider;

0 comments on commit a8be447

Please sign in to comment.