Officiellement migrer à /v5 #15

Merged
vlbeaudoin merged 5 commits from bump/v5 into main 2023-06-02 16:40:45 -04:00
5 changed files with 20 additions and 17 deletions
Showing only changes of commit 764093f99d - Show all commits

View file

@ -41,17 +41,17 @@ var apiCmd = &cobra.Command{
// Routes // Routes
e.GET("/v4/health/", handlers.GetHealth) e.GET("/v5/health/", handlers.GetHealth)
e.POST("/v4/membres/", handlers.PostMembres) e.POST("/v5/membres/", handlers.PostMembres)
e.GET("/v4/membres/:membre_id/", handlers.ReadMembre) e.GET("/v5/membres/:membre_id/", handlers.ReadMembre)
e.PUT("/v4/membres/:membre_id/prefered_name/", handlers.PutMembrePreferedName) e.PUT("/v5/membres/:membre_id/prefered_name/", handlers.PutMembrePreferedName)
e.POST("/v4/programmes/", handlers.PostProgrammes) e.POST("/v5/programmes/", handlers.PostProgrammes)
e.POST("/v4/seed/", handlers.PostSeed) e.POST("/v5/seed/", handlers.PostSeed)
// Execution // Execution

View file

@ -55,7 +55,7 @@ var webCmd = &cobra.Command{
apiClient := data.NewApiClient(webApiKey, webApiHost, webApiProtocol, webApiPort) apiClient := data.NewApiClient(webApiKey, webApiHost, webApiProtocol, webApiPort)
pingResult, err := apiClient.GetV4() pingResult, err := apiClient.GetHealth()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View file

@ -8,8 +8,8 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"git.agecem.com/agecem/bottin/handlers"
"git.agecem.com/agecem/bottin/models" "git.agecem.com/agecem/bottin/models"
"git.agecem.com/agecem/bottin/responses"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -82,9 +82,9 @@ func (a *ApiClient) Call(method, route string, requestBody io.Reader, useKey boo
// GetHealth allows checking for API server health // GetHealth allows checking for API server health
func (a *ApiClient) GetHealth() (string, error) { func (a *ApiClient) GetHealth() (string, error) {
var getHealthResponse handlers.GetHealthResponse var getHealthResponse responses.GetHealth
response, err := a.Call(http.MethodGet, "/v4/health", nil, true) response, err := a.Call(http.MethodGet, "/v5/health", nil, true)
if err != nil { if err != nil {
return getHealthResponse.Message, err return getHealthResponse.Message, err
} }
@ -124,7 +124,7 @@ func (a *ApiClient) GetMembre(membreID string) (models.Membre, error) {
log.Println("ApiClient.GetMembre received membreID: ", membreID) log.Println("ApiClient.GetMembre received membreID: ", membreID)
*/ */
response, err := a.Call(http.MethodGet, fmt.Sprintf("/v4/membres/%s", membreID), nil, true) response, err := a.Call(http.MethodGet, fmt.Sprintf("/v5/membres/%s", membreID), nil, true)
if err != nil { if err != nil {
return getMembreResponse.Data.Membre, err return getMembreResponse.Data.Membre, err
} }

View file

@ -5,16 +5,13 @@ import (
"net/http" "net/http"
"git.agecem.com/agecem/bottin/data" "git.agecem.com/agecem/bottin/data"
"git.agecem.com/agecem/bottin/responses"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )
type GetHealthResponse struct {
Message string `json:"message"`
}
func GetHealth(c echo.Context) error { func GetHealth(c echo.Context) error {
response := GetHealthResponse{ response := responses.GetHealth{
Message: "Bottin API v4 is ready", Message: "Bottin API v5 is ready",
} }
dataClient, err := data.NewDataClientFromViper() dataClient, err := data.NewDataClientFromViper()

6
responses/health.go Normal file
View file

@ -0,0 +1,6 @@
package responses
// GetHealth is the response type for handlers.GetHealth
type GetHealth struct {
Message string `json:"message"`
}