diff options
author | Andinus <andinus@nand.sh> | 2020-03-24 17:41:57 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-24 17:41:57 +0530 |
commit | 813b37d0cf7e6e371418feac56d40f48176105ba (patch) | |
tree | 2e4efd2224ff84700cbf354ea0ff75775d79a8a0 /pkg/request | |
parent | 532c060fd97c31c28f20f6f823472247edc0c30f (diff) | |
download | cetus-813b37d0cf7e6e371418feac56d40f48176105ba.tar.gz |
Reinitialize project and change module url
Diffstat (limited to 'pkg/request')
-rw-r--r-- | pkg/request/req.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/pkg/request/req.go b/pkg/request/req.go deleted file mode 100644 index 350f5f6..0000000 --- a/pkg/request/req.go +++ /dev/null @@ -1,44 +0,0 @@ -package request - -import ( - "fmt" - "io/ioutil" - "net/http" - "time" -) - -// GetRes returns api response -func GetRes(api string, params map[string]string) (string, error) { - c := http.Client{ - // TODO: timeout should be configurable by the user - Timeout: time.Second * 64, - } - - req, err := http.NewRequest(http.MethodGet, api, nil) - if err != nil { - return "", err - } - - q := req.URL.Query() - for k, v := range params { - q.Add(k, v) - } - req.URL.RawQuery = q.Encode() - - res, err := c.Do(req) - if err != nil { - return "", err - } - defer res.Body.Close() - - if res.StatusCode != 200 { - return "", fmt.Errorf("Unexpected response status code received: %d %s", - res.StatusCode, http.StatusText(res.StatusCode)) - } - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - return "", err - } - return string(body), err -} |