Wayan Jimmy's Brain

Attach proxy to HTTP client

related
Golang
link
Setting up proxy for 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)}