GO
Languages & HTTP Clients

Go (net/http) proxy integration

Go's standard library handles proxies through a custom Transport. Parse your Aethyn endpoint into a *url.URL, set it as the Transport's Proxy, and the http.Client routes every request through a residential IP.

Setup steps

  1. 1Parse your Aethyn proxy URL with url.Parse.
  2. 2Create an http.Transport with Proxy: http.ProxyURL(...).
  3. 3Attach the transport to an http.Client.
  4. 4Use the client as normal — targeting lives in the username.

Code

net/http with a proxy transport
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    proxyURL, _ := url.Parse("http://aethyn-XXXXX-country-us:PASSWORD@proxy.aethyn.io:2099")
    client := &http.Client{
        Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
    }

    resp, err := client.Get("https://httpbin.org/ip")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}

Replace aethyn-XXXXX and PASSWORD with your dashboard credentials. See the full targeting reference and protocol/port list.

Tips

  • Set Timeout on the http.Client to avoid hanging on slow exits.
  • Reuse one client/transport for connection pooling.
  • For SOCKS5, use golang.org/x/net/proxy to build a dialer.

Go (net/http) proxy FAQ

Does http.ProxyURL support authentication?
Yes. Embed the username and password in the URL you pass to url.Parse, and Go sends the Proxy-Authorization header automatically.

Ready to wire up Go (net/http)?

Get your credentials and route your first Go (net/http) request through residential IPs in minutes.

Docs, solutions & blog

Related integrations

All integrations