(tested) add hooks check when ping http route called

This commit is contained in:
Lawrence, Rendall
2022-05-14 01:36:21 +03:00
parent cf2adad4c9
commit 79c92df0f8
8 changed files with 70 additions and 11 deletions
+11 -2
View File
@@ -308,6 +308,15 @@ func (f *Frontend) scrapeRoute(w http.ResponseWriter, r *http.Request, ps httpro
go f.logic.AfterScrape(ctx, req, resp)
}
func (f Frontend) ping(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
w.WriteHeader(http.StatusOK)
func (f Frontend) ping(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
var err error
if r.Method == http.MethodGet {
err = f.logic.Ping(context.Background())
}
if err == nil {
w.WriteHeader(http.StatusOK)
} else {
logger.Error().Err(err).Msg("ping completed with error")
w.WriteHeader(http.StatusServiceUnavailable)
}
}