Error on unsupported StatusCode in GetEndpoints
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2018-12-07 21:52:19 +01:00
parent 5c4144444a
commit 17bee2852a
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
@ -40,6 +41,14 @@ func GetEndpoints(me *url.URL) (Endpoints, error) {
}
defer res.Body.Close()
if res.StatusCode != 200 {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return endpoints, fmt.Errorf("error from endpoint while reading body %d", res.StatusCode)
}
return endpoints, fmt.Errorf("error from endpoint %d: %s", res.StatusCode, body)
}
var links linkheader.Links
if headers, e := res.Header["Link"]; e {