Check that API reponse is 200.

This commit is contained in:
Orne Brocaar 2015-07-08 21:28:25 +02:00
parent d38f2223a5
commit 55cfd5c904
1 changed files with 3 additions and 0 deletions

View File

@ -70,6 +70,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error {
if err != nil {
return err
}
if r.StatusCode != http.StatusOK {
return fmt.Errorf("elasticsearch: API responded with status-code %d, expected %d", r.StatusCode, http.StatusOK)
}
d := json.NewDecoder(r.Body)
esRes := &struct {
ClusterName string `json:"cluster_name"`