! Not sure if I'm getting into a bad practice of this should be an expected behaviour
Instantiating a client with the Default http Golang client (client := github.NewClient(http.DefaultClient) leads to the perversion of the http.DefaultClient content, which when used over the rest of the code, starts breaking when for example using a Bearer token as Authorization: It will return 201, appearing the header not being included in the response.
func NewMyController() *MyController {
return &MyController{
client: http.DefaultClient,
baseURL: "myBaseUrl",
}
}
If after making any Github calls with a client := github.NewClient(http.DefaultClient), we run this code
req, _ := http.NewRequest(http.MethodGet, "myUrl", nil)
req.Header.Set("Authorization", "Bearer myToken")
resp, err := http.DefaultClient.Do(req)
fmt.Println(resp.StatusCode)
The http.DefaultClient will seem perverted since it will appear the Authorization header is not being correctly sent, as the retrieved StatusCode will be 201.
Extrainfo: Using go 1.21.4
! Not sure if I'm getting into a bad practice of this should be an expected behaviour
Instantiating a client with the Default http Golang client (
client := github.NewClient(http.DefaultClient)leads to the perversion of the http.DefaultClient content, which when used over the rest of the code, starts breaking when for example using a Bearer token as Authorization: It will return 201, appearing the header not being included in the response.If after making any Github calls with a
client := github.NewClient(http.DefaultClient), we run this codeThe
http.DefaultClientwill seem perverted since it will appear the Authorization header is not being correctly sent, as the retrieved StatusCode will be 201.Extrainfo: Using
go 1.21.4