Attach proxy to HTTP client
Attach proxy to HTTP Client
Construct a http client with a proxy
proxyURL, _ := url.Parse("http://proxyIp:proxyPort")
myClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
We could also modify the default transport used by the net/http
package. This would affect the entire program.
proxyURL, _ := url.Parse("http://proxyIp:proxyPort")
http.DefaultTransport := &http.Transport{Proxy: http.ProxyURL(proxyURL)}