HealthController.cs
578 bytes
| 1 | using Microsoft.AspNetCore.Mvc; |
|---|---|
| 2 | using SplitApp.UsersService.Hosting; |
| 3 | |
| 4 | namespace SplitApp.UsersService.Controllers; |
| 5 | |
| 6 | /// <summary>Non-versioned health endpoint consumed by Docker compose's healthcheck.</summary> |
| 7 | [ApiController] |
| 8 | [Route("health")] |
| 9 | public class HealthController : ControllerBase |
| 10 | { |
| 11 | private readonly SeededHealthState _state; |
| 12 | |
| 13 | public HealthController(SeededHealthState state) => _state = state; |
| 14 | |
| 15 | [HttpGet] |
| 16 | public IActionResult Get() => _state.IsSeeded |
| 17 | ? Ok(new { status = "healthy" }) |
| 18 | : StatusCode(503, new { status = "starting" }); |
| 19 | } |
| 20 | |