Officiellement migrer à /v5 #15

Merged
vlbeaudoin merged 5 commits from bump/v5 into main 2023-06-02 16:40:45 -04:00
Showing only changes of commit 9ac95672b9 - Show all commits

View file

@ -8,6 +8,7 @@ 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"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -79,33 +80,31 @@ func (a *ApiClient) Call(method, route string, requestBody io.Reader, useKey boo
return response, nil return response, nil
} }
// GetV4 allows checking for API v4 server health // GetHealth allows checking for API server health
func (a *ApiClient) GetV4() (string, error) { func (a *ApiClient) GetHealth() (string, error) {
var getV4Response struct { var getHealthResponse handlers.GetHealthResponse
Message string `json:"message"`
}
response, err := a.Call(http.MethodGet, "/v4", nil, true) response, err := a.Call(http.MethodGet, "/v4/health", nil, true)
if err != nil { if err != nil {
return getV4Response.Message, err return getHealthResponse.Message, err
} }
defer response.Body.Close() defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body) body, err := ioutil.ReadAll(response.Body)
if err != nil { if err != nil {
return getV4Response.Message, err return getHealthResponse.Message, err
} }
if err := json.Unmarshal(body, &getV4Response); err != nil { if err := json.Unmarshal(body, &getHealthResponse); err != nil {
return getV4Response.Message, err return getHealthResponse.Message, err
} }
if getV4Response.Message == "" { if getHealthResponse.Message == "" {
return getV4Response.Message, errors.New("Could not confirm that API server is up, no response message") return getHealthResponse.Message, errors.New("Could not confirm that API server is up, no response message")
} }
return getV4Response.Message, nil return getHealthResponse.Message, nil
} }
func (a *ApiClient) GetMembre(membreID string) (models.Membre, error) { func (a *ApiClient) GetMembre(membreID string) (models.Membre, error) {