Add /healthz endpoint

Returns 200 ok if the DB is reachable, 503 if not.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 22:51:00 -04:00
parent 3a6a4b6e9c
commit 78ac8f3677
+9
View File
@@ -142,6 +142,15 @@ func main() {
r.Use(middleware.Recoverer) r.Use(middleware.Recoverer)
r.Use(srv.sessionMiddleware) 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 // Static files
r.Handle("/static/*", http.FileServer(http.FS(staticFS))) r.Handle("/static/*", http.FileServer(http.FS(staticFS)))