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)))