Add JSON health check with database and tablebase status (#106)

This commit is contained in:
2026-11-09 22:24:09 +01:00
parent 4c39f231f1
commit 56d51347b9
4 changed files with 135 additions and 3 deletions
@@ -1,13 +1,17 @@
defmodule ChesstrainerWeb.HealthController do
@moduledoc """
Lightweight health check used by deploys and uptime monitors.
JSON health check used by deploys and uptime monitors.
"""
use ChesstrainerWeb, :controller
def index(conn, _params) do
health = Chesstrainer.Health.status()
status = if health.status == "down", do: :service_unavailable, else: :ok
conn
|> put_resp_content_type("text/plain")
|> send_resp(200, "ok")
|> put_resp_header("x-robots-tag", "noindex")
|> put_status(status)
|> json(health)
end
end