2024-08-11 19:20:09 +03:30
|
|
|
|
using MD.PersianDateTime.Standard;
|
2023-11-05 18:00:05 +03:30
|
|
|
|
using System.Diagnostics;
|
2025-05-12 16:18:01 +03:30
|
|
|
|
using Brizco.Infrastructure.RestServices;
|
2023-11-05 18:00:05 +03:30
|
|
|
|
|
|
|
|
|
|
namespace Brizco.Api.Controllers;
|
|
|
|
|
|
|
|
|
|
|
|
public class HealthController : ICarterModule
|
|
|
|
|
|
{
|
|
|
|
|
|
public void AddRoutes(IEndpointRouteBuilder app)
|
|
|
|
|
|
{
|
|
|
|
|
|
var group = app.NewVersionedApi("Health")
|
|
|
|
|
|
.MapGroup($"health");
|
|
|
|
|
|
|
|
|
|
|
|
group.MapGet("", GetHealth)
|
|
|
|
|
|
.WithDisplayName("CheckHealth")
|
|
|
|
|
|
.HasApiVersion(1.0);
|
|
|
|
|
|
}
|
2025-05-12 16:18:01 +03:30
|
|
|
|
public async Task<IResult> GetHealth([FromServices] IRestApiWrapper apiWrapper)
|
2023-11-05 18:00:05 +03:30
|
|
|
|
{
|
|
|
|
|
|
var version = typeof(Program)?.Assembly.GetName()?.Version?.ToString();
|
|
|
|
|
|
var check = new HealthCheck
|
|
|
|
|
|
{
|
|
|
|
|
|
Health = true,
|
|
|
|
|
|
Version = version ?? string.Empty,
|
2025-05-12 16:18:01 +03:30
|
|
|
|
StartAt = Process.GetCurrentProcess().StartTime.ToString("F"),
|
|
|
|
|
|
StartAtPersian = new PersianDateTime(Process.GetCurrentProcess().StartTime).ToLongDateTimeString(),
|
2023-11-05 18:00:05 +03:30
|
|
|
|
MachineName = Environment.MachineName
|
|
|
|
|
|
};
|
|
|
|
|
|
var process = Process.GetCurrentProcess();
|
|
|
|
|
|
check.TotalMemory = process.PrivateMemorySize64.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
return TypedResults.Ok(check);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|