2023-06-16 15:00:11 +10:00
|
|
|
|
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;
|
2023-05-17 16:00:50 +10:00
|
|
|
|
|
2023-05-17 16:30:13 +10:00
|
|
|
|
namespace PARR.API.Controllers.V1
|
2023-05-17 16:00:50 +10:00
|
|
|
|
{
|
|
|
|
|
|
public class ApiStatusController : BaseApiController
|
|
|
|
|
|
{
|
2023-06-16 15:00:11 +10:00
|
|
|
|
/// <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));
|
|
|
|
|
|
}
|
2023-05-17 16:00:50 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|