Fix HealthGET statuscode et message parfois vide
This commit is contained in:
parent
a98d11f4b4
commit
f3f15dd311
1 changed files with 10 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue