package handler import ( "net/http" "github.com/jackc/pgx/v5/pgxpool" ) type HealthHandler struct { pool *pgxpool.Pool } func NewHealthHandler(pool *pgxpool.Pool) *HealthHandler { return &HealthHandler{pool: pool} } func (h *HealthHandler) Healthz(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, map[string]string{"status": "ok"}) } func (h *HealthHandler) Readyz(w http.ResponseWriter, r *http.Request) { if err := h.pool.Ping(r.Context()); err != nil { writeInternalError(w, r, err, "database unavailable") return } writeJSON(w, http.StatusOK, map[string]string{"status": "ready"}) }