Skip to content

How to use a Proxy and ca cert #122

Closed Answered by aphsa
aphsa asked this question in Support
Dec 17, 2024 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

I end up using this method. Is there a better solution?

    // custom HTTP transport if proxy is enabled
    var transport *http.Transport
    if config.Proxy {
        transport = &http.Transport{
            Proxy: http.ProxyURL(&url.URL{
                Scheme: "http",
                Host:   config.Proxyhostport,
            }),
            TLSClientConfig: tlsConfig,
        }
    }

    // custom HTTP client with timeout
    client := &http.Client{
        Timeout: 15 * time.Second, 
    }
    if config.Proxy {
        client.Transport = transport
    }

    // Fetch the response 
    var body string
    err := requests.
        URL(config.URL).
        Header("Authorization", fmt.S…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@earthboundkid
Comment options

Answer selected by earthboundkid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants