2022-11-16 23:46:24 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2023-01-10 01:21:53 +01:00
|
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
"github.com/notherealmarco/WASAPhoto/service/api/helpers"
|
2022-11-16 23:46:24 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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) {
|
2023-01-10 01:21:53 +01:00
|
|
|
if err := rt.db.Ping(); err != nil {
|
2022-11-16 23:46:24 +01:00
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
|
|
return
|
2023-01-10 01:21:53 +01:00
|
|
|
}
|
|
|
|
helpers.SendStatus(200, w, "Server is live!", rt.baseLogger)
|
2022-11-16 23:46:24 +01:00
|
|
|
}
|