bottin-agenda/handlers/v2.go
Victor Lacasse-Beaudoin 96f8dfa35e Migrate to version 2
2023-05-29 17:58:23 -04:00

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