From ecea53685f548d46514904f79b874882fec25f33 Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Thu, 13 Mar 2025 22:54:16 -0400 Subject: [PATCH] actually return response value --- chord/httpnode/httpnode.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 {