forked from mtusi2026/mtusi2026lab2
ЛР 2: PostgreSQL, сессии, Redis и исследование
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using Messenger.Api.Data;
|
||||
using Messenger.Api.Services;
|
||||
|
||||
namespace Messenger.Api.Endpoints;
|
||||
|
||||
public static class HealthEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapHealthEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
app.MapGet("/health/live", () => Results.Ok(new { status = "ok" }));
|
||||
app.MapGet("/health/ready", async (HttpContext context, AppDatabase database) =>
|
||||
await database.IsReadyAsync()
|
||||
? Results.Ok(new { status = "ok" })
|
||||
: ApiSupport.ApiError(context, 503, "unavailable", "База данных недоступна"));
|
||||
return app;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user