Victor Lacasse-Beaudoin
764093f99d
Remplacer références GetV4 -> GetHealth Ajouter package responses Remplacer handlers.GetHealthResponse -> responses.GetHealth
32 lines
750 B
Go
32 lines
750 B
Go
package handlers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"git.agecem.com/agecem/bottin/data"
|
|
"git.agecem.com/agecem/bottin/responses"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func GetHealth(c echo.Context) error {
|
|
response := responses.GetHealth{
|
|
Message: "Bottin API v5 is ready",
|
|
}
|
|
|
|
dataClient, err := data.NewDataClientFromViper()
|
|
if err != nil {
|
|
response.Message = fmt.Sprintf("Error during data.NewDataClientFromViper(): %s", err)
|
|
|
|
return c.JSON(http.StatusInternalServerError, response)
|
|
}
|
|
defer dataClient.DB.Close()
|
|
|
|
if err = dataClient.DB.Ping(); err != nil {
|
|
response.Message = fmt.Sprintf("Error during dataClient.DB.Ping(): %s", err)
|
|
|
|
return c.JSON(http.StatusInternalServerError, response)
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, response)
|
|
}
|