Files
parr_api/PARR.API/Controllers/V1/ApiStatusController.cs
Mikhail Trubnikov 4c7c5090db fix(api): test ip
2023-12-04 12:02:55 +10:00

50 lines
1.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using System.Reflection;
namespace PARR.API.Controllers.V1
{
public class ApiStatusController : BaseApiController
{
/// <summary>
/// Получить версию и окружение
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpGet(ApiRoutes.ApiStatus.Version)]
public IActionResult GetVersion()
{
var version = Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var response = new ApiVersionResponse
{
Environment = environment,
Version = version
};
return Ok(new Response<ApiVersionResponse>(response, true));
}
/// <summary>
/// Проверка доступности системы
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpGet(ApiRoutes.ApiStatus.Health)]
public IActionResult GetHealth()
{
//Так же можно реализовать проверку связи с БД
//Проверка доступности хранилищ
var response = new ApiHealthResponse { };
return Ok(new Response<ApiHealthResponse>(response, true));
}
}
}