1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

Improve health check endpoint to test database connection

This commit is contained in:
Frédéric Guillot 2021-02-19 18:47:50 -08:00 committed by fguillot
parent c2571f9f47
commit e3c28a6c96
4 changed files with 29 additions and 14 deletions

View file

@ -184,6 +184,11 @@ func setupHandler(store *storage.Storage, pool *worker.Pool) *mux.Router {
ui.Serve(router, store, pool)
router.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
if err := store.Ping(); err != nil {
http.Error(w, "Database Connection Error", http.StatusInternalServerError)
return
}
w.Write([]byte("OK"))
}).Name("healthcheck")