Mettre à jour avec bottin api v5
This commit is contained in:
parent
bcd12582f1
commit
8adb253f47
6 changed files with 31 additions and 29 deletions
|
@ -67,33 +67,36 @@ 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"`
|
||||
}
|
||||
// BottinHealthResponse is the response type for GetBottinHealth
|
||||
type BottinHealthResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
response, err := a.Call(http.MethodGet, "/v4", nil, true)
|
||||
// GetHealth allows checking for API server health
|
||||
func (a *ApiClient) GetBottinHealth() (string, error) {
|
||||
var healthResponse BottinHealthResponse
|
||||
|
||||
response, err := a.Call(http.MethodGet, "/v4/health", nil, true)
|
||||
if err != nil {
|
||||
return getV4Response.Message, err
|
||||
return healthResponse.Message, err
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return getV4Response.Message, err
|
||||
return healthResponse.Message, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, &getV4Response); err != nil {
|
||||
return getV4Response.Message, err
|
||||
if err := json.Unmarshal(body, &healthResponse); err != nil {
|
||||
return healthResponse.Message, err
|
||||
}
|
||||
|
||||
if getV4Response.Message == "" {
|
||||
return getV4Response.Message, errors.New("Could not confirm that API server is up, no response message")
|
||||
if healthResponse.Message == "" {
|
||||
return healthResponse.Message, errors.New("Could not confirm that API server is up, no response message")
|
||||
}
|
||||
|
||||
return getV4Response.Message, nil
|
||||
return healthResponse.Message, nil
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Reference in a new issue