using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { /// /// Controller that exposes simple health and readiness endpoints for the API. /// Routes are prefixed with "api/health". /// [ApiController] [Route("api/[controller]")] public sealed class HealthController : ControllerBase { /// /// Liveness probe. /// Indicates whether the process is running. Used by orchestration systems to confirm the process is alive. /// /// /// 200 OK with JSON payload: { "status": "alive" } when the process is running. /// // GET api/health/live [HttpGet("live")] public IActionResult Live() => Ok(new { status = "alive" }); /// /// Basic health check endpoint. /// Returns overall status and the current server time in UTC. /// /// /// 200 OK with JSON payload: { "status": "ok", "time": <UTC time> }. /// // GET api/health [HttpGet] public IActionResult Health() => Ok(new { status = "ok", time = DateTimeOffset.UtcNow }); /// /// Echo endpoint. /// Returns the received JSON payload unchanged. Useful for testing request/response plumbing. /// /// Arbitrary JSON from the request body. The endpoint returns the same object. /// 200 OK with the same JSON payload provided in the request body. // POST api/health/echo [HttpPost("echo")] public IActionResult Echo(object payload) => Ok(payload); /// /// Readiness probe. /// Indicates whether the service is ready to accept traffic. Typically checks downstream dependencies. /// /// /// 200 OK with JSON { "status": "ready" } when ready; /// 503 Service Unavailable with JSON { "status": "not_ready" } when not ready. /// // GET api/health/ready [HttpGet("ready")] public IActionResult Ready() { var ready = true; return ready ? Ok(new { status = "ready" }) : StatusCode(503, new { status = "not_ready" }); } } }