From 78ac8f36771c79f99049cc138a511c0f12c0f2ba Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Mon, 18 May 2026 22:51:00 -0400 Subject: [PATCH] Add /healthz endpoint Returns 200 ok if the DB is reachable, 503 if not. Co-Authored-By: Claude Opus 4.6 --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 2f9d183..6f3f9d1 100644 --- a/main.go +++ b/main.go @@ -142,6 +142,15 @@ func main() { r.Use(middleware.Recoverer) r.Use(srv.sessionMiddleware) + // Health check + r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { + if err := database.PingContext(r.Context()); err != nil { + http.Error(w, "db down", http.StatusServiceUnavailable) + return + } + w.Write([]byte("ok")) + }) + // Static files r.Handle("/static/*", http.FileServer(http.FS(staticFS)))