SetProxy configures the provided HTTP client with proxy settings from the configuration. It supports SOCKS5, HTTP, and HTTPS proxies. The function modifies the client's transport to route requests through the configured proxy server.
(cfg *config.SDKConfig, httpClient *http.Client)
| 15 | // It supports SOCKS5, HTTP, and HTTPS proxies. The function modifies the client's transport |
| 16 | // to route requests through the configured proxy server. |
| 17 | func SetProxy(cfg *config.SDKConfig, httpClient *http.Client) *http.Client { |
| 18 | if cfg == nil || httpClient == nil { |
| 19 | return httpClient |
| 20 | } |
| 21 | |
| 22 | transport, _, errBuild := proxyutil.BuildHTTPTransport(cfg.ProxyURL) |
| 23 | if errBuild != nil { |
| 24 | log.Errorf("%v", errBuild) |
| 25 | } |
| 26 | if transport != nil { |
| 27 | httpClient.Transport = transport |
| 28 | } |
| 29 | return httpClient |
| 30 | } |
no test coverage detected