Skip to content

Commit

Permalink
add health check
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorHallman authored and biegehydra committed Oct 22, 2023
1 parent 49626c2 commit f48fb22
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions LibPostalApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<ILibPostalService, LibPostalService>();

builder.Services.AddHealthChecks();


var app = builder.Build();

// Configure the HTTP request pipeline.
Expand All @@ -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();

0 comments on commit f48fb22

Please sign in to comment.