mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-03-13 13:35:23 +01:00
18 lines
605 B
Go
18 lines
605 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
"github.com/notherealmarco/WASAPhoto/service/api/helpers"
|
|
)
|
|
|
|
// liveness is an HTTP handler that checks the API server status. If the server cannot serve requests (e.g., some
|
|
// resources are not ready), this should reply with HTTP Status 500. Otherwise, with HTTP Status 200
|
|
func (rt *_router) liveness(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
if err := rt.db.Ping(); err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
helpers.SendStatus(200, w, "Server is live!", rt.baseLogger)
|
|
}
|