I want http.Client
to add additional header for all requests.
type MyClient struct {
http.Client
}
func (c *MyClient) Do(req *http.Request) (*http.Response, error) {
req.Header.Add("User-Agent", "go")
return c.Client.Do(req)
}
func Do
never gets called if I call func PostForm
that is using Do
. If there is no way how to mimic OOP, how to do it least painfully?