Merge pull request 'Retirer réimplémentation de bottin health' (#18) from cleanup/remove-GetBottinHealth into main
Reviewed-on: #18
This commit is contained in:
commit
7773b3cf72
1 changed files with 0 additions and 35 deletions
|
@ -1,11 +1,8 @@
|
||||||
package data
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,35 +58,3 @@ func (a *ApiClient) Call(method, route string, requestBody io.Reader, useKey boo
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BottinHealthResponse is the response type for GetBottinHealth
|
|
||||||
type BottinHealthResponse struct {
|
|
||||||
Message string `json:"message"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 healthResponse.Message, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer response.Body.Close()
|
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
|
||||||
if err != nil {
|
|
||||||
return healthResponse.Message, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := json.Unmarshal(body, &healthResponse); err != nil {
|
|
||||||
return healthResponse.Message, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if healthResponse.Message == "" {
|
|
||||||
return healthResponse.Message, errors.New("Could not confirm that API server is up, no response message")
|
|
||||||
}
|
|
||||||
|
|
||||||
return healthResponse.Message, nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue