diff --git a/chord/httpnode/httpnode.go b/chord/httpnode/httpnode.go index 81022f1..eb9706d 100644 --- a/chord/httpnode/httpnode.go +++ b/chord/httpnode/httpnode.go @@ -28,6 +28,9 @@ func writeError(w http.ResponseWriter, status int, msg string) { } func readResponse[T any](r *http.Response) (x T, err error) { + if r.StatusCode != http.StatusOK { + return x, errors.New(r.Status) + } var b struct { Data T `json:"data"` Error string `json:"error"` @@ -38,7 +41,7 @@ func readResponse[T any](r *http.Response) (x T, err error) { if b.Error != "" { return x, errors.New(b.Error) } - return x, nil + return b.Data, nil } type neighbors struct {