using Microsoft.AspNetCore.Mvc; using Idoklad.Configuration; namespace Idoklad.Controllers; /// Service metadata endpoints. These do not require iDoklad credentials. [ApiController] [Produces("application/json")] [Tags("Meta")] public sealed class MetaController : ControllerBase { private readonly IdokladSettings _settings; public MetaController(IdokladSettings settings) => _settings = settings; /// Liveness probe. [HttpGet("/health")] public IActionResult Health() => Ok(new { status = "ok" }); /// Service name, version and language. [HttpGet("/version")] public IActionResult Version() => Ok(new { app = _settings.AppName, version = _settings.AppVersion, language = "dotnet", sdk = "IdokladSdk 5.3.0", root_path = _settings.RootPath, }); /// /// Reports whether the service has default iDoklad credentials configured through /// environment variables. Per-request callers can always override them with headers. /// [HttpGet("/status")] public IActionResult Status() => Ok(new { default_credentials_configured = _settings.HasDefaultCredentials, client_id = !string.IsNullOrWhiteSpace(_settings.ClientId), client_secret = !string.IsNullOrWhiteSpace(_settings.ClientSecret), application_id = !string.IsNullOrWhiteSpace(_settings.ApplicationId), custom_urls = _settings.HasCustomUrls, idoklad_language = _settings.Language.ToString(), }); }