2023-05-29 17:58:23 -04:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-06-03 19:48:37 -04:00
|
|
|
bottindata "git.agecem.com/agecem/bottin/v5/data"
|
2023-05-29 17:58:23 -04:00
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
2023-06-03 19:48:37 -04:00
|
|
|
func GetHealth(c echo.Context) error {
|
2023-05-29 17:58:23 -04:00
|
|
|
bottinApiKey := viper.GetString("bottin.api.key")
|
|
|
|
bottinApiHost := viper.GetString("bottin.api.host")
|
|
|
|
bottinApiProtocol := viper.GetString("bottin.api.protocol")
|
|
|
|
bottinApiPort := viper.GetInt("bottin.api.port")
|
|
|
|
|
2023-06-03 19:48:37 -04:00
|
|
|
bottinConnection := bottindata.NewApiClient(
|
2023-05-29 17:58:23 -04:00
|
|
|
bottinApiKey,
|
|
|
|
bottinApiHost,
|
|
|
|
bottinApiProtocol,
|
|
|
|
bottinApiPort,
|
|
|
|
)
|
|
|
|
|
|
|
|
var bottinStatus string
|
|
|
|
|
2023-06-03 19:48:37 -04:00
|
|
|
healthResponse, err := bottinConnection.GetHealth()
|
2023-05-29 17:58:23 -04:00
|
|
|
if err != nil {
|
|
|
|
bottinStatus = err.Error()
|
|
|
|
} else {
|
2023-06-03 19:48:37 -04:00
|
|
|
bottinStatus = healthResponse
|
2023-05-29 17:58:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, map[string]string{
|
|
|
|
"message": "Bottin-agenda API v2 is ready",
|
|
|
|
"bottin": bottinStatus,
|
|
|
|
})
|
|
|
|
}
|