forked from mtusi2026/mtusi2026lab2
18 lines
631 B
C#
18 lines
631 B
C#
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;
|
|
}
|
|
}
|