From 67b0b54eeafb83e815c99321202b7b32e74a066f Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Sun, 16 Nov 2025 18:06:36 +0100 Subject: [PATCH] Refactor - simplify code --- api/rest/http.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/api/rest/http.go b/api/rest/http.go index b38b37c..a89449d 100644 --- a/api/rest/http.go +++ b/api/rest/http.go @@ -27,29 +27,19 @@ func (c *HttpClient) SendGet(url string, data, out any) error { decoder := json.NewDecoder(res.Body) defer res.Body.Close() - err = decoder.Decode(&out) - if err != nil { - return err - } - - return nil + return decoder.Decode(&out) } -func (c *HttpClient) SendPost(url string, data, out any) (any, error) { +func (c *HttpClient) SendPost(url string, data, out any) error { res, err := c.sendRequest(url, http.MethodPost, data) if err != nil { - return nil, err + return err } decoder := json.NewDecoder(res.Body) defer res.Body.Close() - err = decoder.Decode(out) - if err != nil { - return nil, err - } - - return out, nil + return decoder.Decode(&out) } func (c *HttpClient) sendRequest(url, method string, data any) (*http.Response, error) {