Migrate to version 2
This commit is contained in:
parent
4ac3625f45
commit
96f8dfa35e
21 changed files with 777 additions and 746 deletions
37
handlers/v2.go
Normal file
37
handlers/v2.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
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,
|
||||
})
|
||||
}
|
Reference in a new issue