From 764093f99d2993db8df7ab6773b5b39c539f8928 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 2 Jun 2023 16:33:13 -0400 Subject: [PATCH] Bump routes v4 -> v5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remplacer références GetV4 -> GetHealth Ajouter package responses Remplacer handlers.GetHealthResponse -> responses.GetHealth --- cmd/api.go | 12 ++++++------ cmd/web.go | 2 +- data/apiclient.go | 8 ++++---- handlers/health.go | 9 +++------ responses/health.go | 6 ++++++ 5 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 responses/health.go diff --git a/cmd/api.go b/cmd/api.go index a7317b1..1044c34 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -41,17 +41,17 @@ var apiCmd = &cobra.Command{ // 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 diff --git a/cmd/web.go b/cmd/web.go index adf7de3..c773b56 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -55,7 +55,7 @@ var webCmd = &cobra.Command{ apiClient := data.NewApiClient(webApiKey, webApiHost, webApiProtocol, webApiPort) - pingResult, err := apiClient.GetV4() + pingResult, err := apiClient.GetHealth() if err != nil { log.Fatal(err) } diff --git a/data/apiclient.go b/data/apiclient.go index 21ceecc..1eef66a 100644 --- a/data/apiclient.go +++ b/data/apiclient.go @@ -8,8 +8,8 @@ import ( "io/ioutil" "net/http" - "git.agecem.com/agecem/bottin/handlers" "git.agecem.com/agecem/bottin/models" + "git.agecem.com/agecem/bottin/responses" "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 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 { return getHealthResponse.Message, err } @@ -124,7 +124,7 @@ func (a *ApiClient) GetMembre(membreID string) (models.Membre, error) { 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 { return getMembreResponse.Data.Membre, err } diff --git a/handlers/health.go b/handlers/health.go index 99cc498..5292e56 100644 --- a/handlers/health.go +++ b/handlers/health.go @@ -5,16 +5,13 @@ import ( "net/http" "git.agecem.com/agecem/bottin/data" + "git.agecem.com/agecem/bottin/responses" "github.com/labstack/echo/v4" ) -type GetHealthResponse struct { - Message string `json:"message"` -} - func GetHealth(c echo.Context) error { - response := GetHealthResponse{ - Message: "Bottin API v4 is ready", + response := responses.GetHealth{ + Message: "Bottin API v5 is ready", } dataClient, err := data.NewDataClientFromViper() diff --git a/responses/health.go b/responses/health.go new file mode 100644 index 0000000..6d5e663 --- /dev/null +++ b/responses/health.go @@ -0,0 +1,6 @@ +package responses + +// GetHealth is the response type for handlers.GetHealth +type GetHealth struct { + Message string `json:"message"` +}