From ccdf90d2a2a6d8deb9782d62b4180f266d2761d9 Mon Sep 17 00:00:00 2001 From: Corentin Barreau Date: Wed, 6 Nov 2024 22:17:28 +0100 Subject: [PATCH] fix: DELETE eof --- delete.go | 19 ++++++------------- models.go | 4 ---- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/delete.go b/delete.go index 7b0027e..785af9c 100644 --- a/delete.go +++ b/delete.go @@ -7,9 +7,8 @@ import ( "net/http" ) -func (c *Client) Delete(URLs []URL, localCrawls int) (finishedResponse *DeleteResponse, err error) { +func (c *Client) Delete(URLs []URL, localCrawls int) (err error) { expectedStatusCode := 204 - finishedResponse = new(DeleteResponse) // build payload payload := DeletePayload{ @@ -19,13 +18,13 @@ func (c *Client) Delete(URLs []URL, localCrawls int) (finishedResponse *DeleteRe jsonPayload, err := json.Marshal(payload) if err != nil { - return finishedResponse, err + return err } // build request req, err := http.NewRequest("DELETE", c.URLsEndpoint.String(), bytes.NewReader(jsonPayload)) if err != nil { - return finishedResponse, err + return err } req.Header.Add("X-Auth-Key", c.Key) @@ -39,20 +38,14 @@ func (c *Client) Delete(URLs []URL, localCrawls int) (finishedResponse *DeleteRe // execute request resp, err := c.HTTPClient.Do(req) if err != nil { - return finishedResponse, err + return err } defer resp.Body.Close() // check response status code if resp.StatusCode != expectedStatusCode { - return finishedResponse, fmt.Errorf("non-%d status code: %d", expectedStatusCode, resp.StatusCode) + return fmt.Errorf("non-%d status code: %d", expectedStatusCode, resp.StatusCode) } - // decode response body - err = json.NewDecoder(resp.Body).Decode(finishedResponse) - if err != nil { - return finishedResponse, err - } - - return finishedResponse, err + return err } diff --git a/models.go b/models.go index 829bb58..91228b5 100644 --- a/models.go +++ b/models.go @@ -37,10 +37,6 @@ type GetResponse struct { URLs []URL `json:"urls"` } -type DeleteResponse struct { - Project string `json:"project"` -} - type AddPayload struct { URLs []URL `json:"urls"` BypassSeencheck bool `json:"bypassSeencheck"`