From 0eb32bb339f66d3416c1088d6372bc7219b6e323 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 6 Feb 2022 19:02:33 +0530 Subject: now a single http.Client is responsible for all the HTTP requests. --- anime/util.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'anime/util.go') 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) } -- cgit v1.2.3