Documentation
¶
Overview ¶
Package httpproxyfailover provides a means to construct a fault-tolerant HTTP proxy out of multiple somewhat unreliable HTTP proxies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proxy ¶
type Proxy struct { // Backends hold backend HTTP proxies. Proxy tries backend HTTP proxies in order of the slice and use the first one // that responds with a successful status code (2XX). Backends []string // Timeout sets the deadline of trial of each backend HTTP proxy if provided. Timeout time.Duration // TLSHandshake requires further check on each backend. If set, a backend which speaks TLS is considered available // if not only it responds a CONNECT request with a successful status code (2XX) but also a TLS handshake succeeds. // This check occurs in a different TCP connection. So there's no guarantee that the proxy connection also succeeds // with a TLS handshake. TLSHandshake *tls.Config // Callback is signaled after every trial of the backend HTTP proxies if provided. // The first argument is the CONNECT request, the second argument is the backend HTTP proxy in trial, and the last // argument is the resulting error which is nil if it succeeded. Callback func(*http.Request, string, error) // contains filtered or unexported fields }
Proxy is a proxy for backend HTTP proxies.
func (*Proxy) EnableTemplates ¶ added in v0.3.0
EnableTemplates() parses backends as URI templates. Proxy will connect to only applicable backends which template variables are satisfied. The values for template variables are populated from the credentials in Proxy-Authorization header. The substring before the first ':' (usually considered as username) should be the form of a list of key-value pairs (`k1=v1,k2=v2`). Each pair is separated by '=' without whitespaces, and those pairs are separated by ',' without whitespaces. Optionally, you can omit '=' and the value (`k1=v1,k2=v2,tag`). Then it's considered a pair of the key and empty string (`k1=v1,k2=v2,tag=`).