38 lines
791 B
Go
38 lines
791 B
Go
|
package handlers
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"git.agecem.com/agecem/bottin-agenda/data"
|
||
|
"github.com/labstack/echo/v4"
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
func GetV2(c echo.Context) error {
|
||
|
bottinApiKey := viper.GetString("bottin.api.key")
|
||
|
bottinApiHost := viper.GetString("bottin.api.host")
|
||
|
bottinApiProtocol := viper.GetString("bottin.api.protocol")
|
||
|
bottinApiPort := viper.GetInt("bottin.api.port")
|
||
|
|
||
|
bottinConnection := data.NewApiClient(
|
||
|
bottinApiKey,
|
||
|
bottinApiHost,
|
||
|
bottinApiProtocol,
|
||
|
bottinApiPort,
|
||
|
)
|
||
|
|
||
|
var bottinStatus string
|
||
|
|
||
|
message, err := bottinConnection.GetV4()
|
||
|
if err != nil {
|
||
|
bottinStatus = err.Error()
|
||
|
} else {
|
||
|
bottinStatus = message
|
||
|
}
|
||
|
|
||
|
return c.JSON(http.StatusOK, map[string]string{
|
||
|
"message": "Bottin-agenda API v2 is ready",
|
||
|
"bottin": bottinStatus,
|
||
|
})
|
||
|
}
|