package http import ( "net/http" "gitea.privcloud.tech/mtusi2026/internal/gen/contracts" "gitea.privcloud.tech/mtusi2026/internal/pkg/apperr" "gitea.privcloud.tech/mtusi2026/internal/pkg/rest/framework" "gitea.privcloud.tech/mtusi2026/internal/pkg/rest/router" ) type HealthHandler struct { router router.Router server Server } func NewHealthHandler(r router.Router, server Server) Handler { return &HealthHandler{ router: r, server: server, } } func (h *HealthHandler) RegisterRoutes() { h.router.Public(http.MethodGet, "/health/ready", h.Ready) h.router.Public(http.MethodGet, "/health/live", h.Live) } func (h *HealthHandler) Live(w http.ResponseWriter, _ *http.Request) { framework.JSONResponse(w, http.StatusOK, contracts.Health{Status: contracts.Ok}) } func (h *HealthHandler) Ready(w http.ResponseWriter, r *http.Request) { if !h.server.Ready() { framework.JSONError(r.Context(), w, apperr.New(apperr.CodeUnavailable, "server is not ready")) return } framework.JSONResponse(w, http.StatusOK, contracts.Health{Status: contracts.Ok}) }