92 lines
2.9 KiB
C#
92 lines
2.9 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
using Landmark.OLA.Application.Services;
|
|
using Landmark.OLA.Models;
|
|
using Serilog;
|
|
|
|
namespace Landmark.OLA.Application.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class StatusController : ControllerBase
|
|
{
|
|
private readonly IStatus _status;
|
|
private readonly ApplicationControlConfiguration _appControlConfig;
|
|
private readonly CoreSettings _coreSettings;
|
|
|
|
public StatusController(IOptions<ApplicationControlConfiguration> settings,
|
|
IStatus status,
|
|
CoreSettings coreSettings)
|
|
{
|
|
_appControlConfig = settings.Value;
|
|
_status = status;
|
|
_coreSettings = coreSettings;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attempts to load the root of the API result in a web-app redirect.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Cookies: None required or set.
|
|
/// Security: None required or provided.
|
|
/// </remarks>
|
|
// GET: Root
|
|
[HttpGet()]
|
|
[ProducesResponseType(302)]
|
|
public void GetRoot()
|
|
{
|
|
HttpContext.Response.Redirect(_appControlConfig.HomePageUrl);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use to get the status of the api
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Returns a simple object describing the build time, version, and environment of the running API.
|
|
/// Cookies: None required or set.
|
|
/// Security: None required or provided.
|
|
/// </remarks>
|
|
// GET: api/Status
|
|
[HttpGet("api/Status")]
|
|
[ProducesResponseType(typeof(IStatus), 200)]
|
|
[ProducesResponseType(500)]
|
|
public IActionResult Get()
|
|
{
|
|
try
|
|
{
|
|
return new ObjectResult(_status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e.Message);
|
|
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use to get the core connection settings of the api
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Returns a simple object describing the core settings being used by the API.
|
|
/// Cookies: None required or set.
|
|
/// Security: None required or provided.
|
|
/// </remarks>
|
|
// GET: api/Status
|
|
[HttpGet("api/GetCoreConnection")]
|
|
[ProducesResponseType(typeof(CoreSettings), 200)]
|
|
[ProducesResponseType(500)]
|
|
public IActionResult GetCoreConnection()
|
|
{
|
|
try
|
|
{
|
|
return new ObjectResult(_coreSettings);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e.Message);
|
|
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
|
}
|
|
}
|
|
}
|
|
} |