53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using Asp.Versioning;
|
|
using GerstITS.Authentication.ApiKey;
|
|
using GerstITS.Examples.Api.Versioning;
|
|
using GerstITS.System.Environment;
|
|
using GerstITS.Validation;
|
|
using GerstITS.Web.Api;
|
|
using GerstITS.Web.Api.FluentApi;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace GerstITS.Examples.Api.Controllers._1._1;
|
|
|
|
/// <summary>
|
|
/// Is responsible to provide maintenance functions protected by an api key header.
|
|
/// </summary>
|
|
[ApiController,
|
|
ApiVersion(Versions._1_1),
|
|
ApiKey,
|
|
Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)]
|
|
public class MaintenanceController : FluentApiControllerBase
|
|
{
|
|
#region Fields
|
|
|
|
private readonly ISystemClock _systemClock;
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public MaintenanceController(ISystemClock systemClock,
|
|
IValidator validator)
|
|
: base(validator)
|
|
{
|
|
_systemClock = systemClock;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Gets the current server time. Requires a valid api key header.
|
|
/// </summary>
|
|
/// <returns>Returns the current server time.</returns>
|
|
[HttpGet,
|
|
Route("Ping")]
|
|
public IActionResult Ping()
|
|
{
|
|
return Api().Get(() => _systemClock.UtcNow);
|
|
}
|
|
|
|
#endregion
|
|
}
|