Bump routes v4 -> v5
Remplacer références GetV4 -> GetHealth Ajouter package responses Remplacer handlers.GetHealthResponse -> responses.GetHealth
This commit is contained in:
parent
9ac95672b9
commit
764093f99d
5 changed files with 20 additions and 17 deletions
12
cmd/api.go
12
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
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
6
responses/health.go
Normal file
6
responses/health.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package responses
|
||||
|
||||
// GetHealth is the response type for handlers.GetHealth
|
||||
type GetHealth struct {
|
||||
Message string `json:"message"`
|
||||
}
|
Reference in a new issue