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