From f3f15dd3117ee717dd04805dc1d60d8a5362985b Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sat, 16 Sep 2023 19:16:43 -0400 Subject: [PATCH] Fix HealthGET statuscode et message parfois vide --- apihandler/apihandler.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apihandler/apihandler.go b/apihandler/apihandler.go index 1339e8e..a7a21bf 100644 --- a/apihandler/apihandler.go +++ b/apihandler/apihandler.go @@ -41,15 +41,24 @@ type APIHandler struct { func (a *APIHandler) HealthGET(c echo.Context) error { var r apiresponse.HealthGET + r.Message = "not ok" + bottinStatus, err := a.BottinAPIClient.GetHealth() if err != nil { - r.Message = "not ok" r.StatusCode = http.StatusInternalServerError r.Data.BottinStatus = err.Error() } else { r.Data.BottinStatus = bottinStatus } + switch r.Data.BottinStatus { + case "Bottin API v5 is ready": + r.Message = "ok" + r.StatusCode = http.StatusOK + default: + r.StatusCode = http.StatusInternalServerError + } + return c.JSON(r.StatusCode, r) }