Victor Lacasse-Beaudoin
a8dcdd0388
Tag v6.0.0 est sorti mais n'était pas réflété dans le code. BREAKING: API est maintenant exposé sur `/v6` et non `/v5`
36 lines
925 B
Go
36 lines
925 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.agecem.com/agecem/bottin/v6/data"
|
|
"git.agecem.com/agecem/bottin/v6/responses"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func (h *Handler) GetHealth(c echo.Context) error {
|
|
var response responses.GetHealthResponse
|
|
|
|
dataClient, err := data.NewDataClientFromViper()
|
|
if err != nil {
|
|
response.StatusCode = http.StatusInternalServerError
|
|
response.Message = "Error during data.NewDataClientFromViper()"
|
|
response.Error = err.Error()
|
|
|
|
return c.JSON(response.StatusCode, response)
|
|
}
|
|
defer dataClient.DB.Close()
|
|
|
|
if err = dataClient.DB.Ping(); err != nil {
|
|
response.StatusCode = http.StatusInternalServerError
|
|
response.Message = "Error during dataClient.DB.Ping()"
|
|
response.Error = err.Error()
|
|
|
|
return c.JSON(response.StatusCode, response)
|
|
}
|
|
|
|
response.StatusCode = http.StatusOK
|
|
response.Message = "Bottin API v6 is ready"
|
|
|
|
return c.JSON(response.StatusCode, response)
|
|
}
|