Documentation ¶
Overview ¶
Example ¶
package main import ( "log" "net/http" http_ "github.com/searKing/golang/go/net/http" "github.com/searKing/golang/go/net/http/httpproxy" _ "github.com/searKing/golang/go/net/resolver/passthrough" ) func main() { req, _ := http.NewRequest("GET", "http://example.com", nil) proxy := &httpproxy.Proxy{ ProxyUrl: "socks5://proxy.example.com:8080", ProxyTarget: "127.0.0.1", } req = req.WithContext(httpproxy.WithProxy(req.Context(), proxy)) _, err := http_.DefaultTransportWithDynamicProxy.RoundTrip(req) if err != nil { log.Fatal(err) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Proxy ¶
type Proxy struct { // ProxyUrl is proxy's url, like socks5://127.0.0.1:8080 ProxyUrl string // ProxyTarget is as like gRPC Naming for proxy service discovery, with Host in ProxyUrl replaced if not empty. ProxyTarget string // ProxyAddrResolved is the proxy's addr resolved and picked from resolver. ProxyAddrResolved resolver.Address }
Proxy specifies ProxyUrl and ProxyTarget to return a dynamic proxy.
func ContextProxy ¶
ContextProxy returns the Proxy associated with the provided context. If none, it returns nil.
Click to show internal directories.
Click to hide internal directories.