gojek / heimdall

An enhanced HTTP client for Go
http://gojek.tech
Apache License 2.0
2.63k stars 214 forks source link

not able to pass token in headers #64

Closed MuthukumarHelios closed 5 years ago

MuthukumarHelios commented 5 years ago

my http get method call using heimdall

timeout := 1000 * time.Second
    client := httpclient.NewClient(httpclient.WithHTTPTimeout(timeout)
    req, err := client.Get(api, r.Header)

-- If i set the header its working else its an unmarshal error heimdall code

// Get makes a HTTP GET request to provided URL
func (c *Client) Get(url string, headers http.Header) (*http.Response, error) {
    var response *http.Response
    request, _ := http.NewRequest(http.MethodGet, url, nil)

    request.Header.Set("Authorization", headers["Authorization"][0])
    request.Header = headers
//if i add the below line code my api returns success response
request.Header.Set("Authorization", request.Header["Authorization"][0])
    return c.Do(request)
}

heimdall code ref