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:
@@ -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)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user