add healthcheck.

This commit is contained in:
Miroslav Šedivý
2021-03-19 15:04:01 +01:00
parent cd15e0b03e
commit 5a79212b32
3 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,11 @@ func (api *ApiManagerCtx) Route(r chi.Router) {
r.Route(path, router)
}
})
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
//nolint
w.Write([]byte("true"))
})
}
func (api *ApiManagerCtx) Authenticate(next http.Handler) http.Handler {

View File

@ -13,6 +13,12 @@ func Logger(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
req := map[string]interface{}{}
// exclude healthcheck from logs
if r.RequestURI == "/api/health" {
next.ServeHTTP(w, r)
return
}
if reqID := middleware.GetReqID(r.Context()); reqID != "" {
req["id"] = reqID
}