diff --git a/LibPostalApi/Program.cs b/LibPostalApi/Program.cs index 118c9f2..853d37a 100644 --- a/LibPostalApi/Program.cs +++ b/LibPostalApi/Program.cs @@ -11,6 +11,9 @@ builder.Services.AddSwaggerGen(); builder.Services.AddSingleton(); +builder.Services.AddHealthChecks(); + + var app = builder.Build(); // Configure the HTTP request pipeline. @@ -20,10 +23,19 @@ app.UseSwaggerUI(); } -app.UseHttpsRedirection(); +app.MapControllers(); -app.UseAuthorization(); +app.MapHealthChecks("/health"); -app.MapControllers(); +app.Use(async (context, next) => +{ + if (context.Request.Path.StartsWithSegments("/health")) + { + Console.WriteLine($"Health check endpoint called at {DateTime.UtcNow}"); + } + + // Call the next middleware in the pipeline + await next.Invoke(); +}); app.Run();