From d259e3b4110a0413728012598f716cdad4925cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Abdelkader=20Mart=C3=ADnez=20P=C3=A9rez?= Date: Thu, 3 Oct 2019 14:10:48 +0200 Subject: [PATCH] Replace implementation with kapow/http/response --- internal/client/get.go | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/internal/client/get.go b/internal/client/get.go index f89989a..9d7078b 100644 --- a/internal/client/get.go +++ b/internal/client/get.go @@ -1,30 +1,13 @@ package client import ( - "errors" "io" - "net/http" - "strings" -) -func getReason(r *http.Response) string { - return strings.Join(strings.Split(r.Status, " ")[1:], " ") -} + "github.com/BBVA/kapow/http" +) //GetData will perform the request and write the results on the provided writer func GetData(host, id, path string, wr io.Writer) error { url := host + "/handlers/" + id + path - - res, err := http.Get(url) - if err != nil { - return err - } - defer res.Body.Close() - - if res.StatusCode < 200 || res.StatusCode >= 300 { - return errors.New(getReason(res)) - } - - _, err = io.Copy(wr, res.Body) - return err + return http.Do("GET", url, nil, wr) }