aboutsummaryrefslogtreecommitdiff
path: root/anime/util.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-06 19:02:33 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-06 19:02:33 +0530
commit0eb32bb339f66d3416c1088d6372bc7219b6e323 (patch)
treebc5b2a5f60748f60d49f97d9eb934891369fb60e /anime/util.go
parent0d97d71e135cf4fda87acaea56a376c264f90a59 (diff)
now a single http.Client is responsible for all the HTTP requests.
Diffstat (limited to 'anime/util.go')
-rw-r--r--anime/util.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/anime/util.go b/anime/util.go
index f1f3b2a..862b54d 100644
--- a/anime/util.go
+++ b/anime/util.go
@@ -25,18 +25,16 @@ import (
// Handles HTTP request with your OAuth token as a Header
// TODO: Verify that this function is safe to use
-func requestHandler(token string, endpoint string) string {
- client := &http.Client{}
-
+func (c AnimeClient) requestHandler(endpoint string) string {
// generate request
req, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
log.Fatal(err)
}
- req.Header.Add("Authorization", token)
+ req.Header.Add("Authorization", c.AuthToken)
// do request
- res, err := client.Do(req)
+ res, err := c.HttpClient.Do(req)
if err != nil {
log.Fatal(err)
}