32 lines
756 B
Go
32 lines
756 B
Go
package handlers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"git.agecem.com/agecem/bottin/v5/data"
|
|
"git.agecem.com/agecem/bottin/v5/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)
|
|
}
|