bottin/handlers/health.go
Victor Lacasse-Beaudoin a8dcdd0388 chores!: bump API et go mod à v6
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`
2024-01-05 14:38:48 -05:00

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)
}