Documentation ¶
Overview ¶
Package proxy provides transport and upgrade support for proxies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorResponder ¶
type ErrorResponder interface {
Error(w http.ResponseWriter, req *http.Request, err error)
}
ErrorResponder abstracts error reporting to the proxy handler to remove the need to hardcode a particular error format.
func NewErrorResponder ¶
func NewErrorResponder(r SimpleErrorResponder) ErrorResponder
type SimpleErrorResponder ¶
type SimpleErrorResponder interface {
Error(err error)
}
SimpleErrorResponder is the legacy implementation of ErrorResponder for callers that only service a single request/response per proxy.
type Transport ¶
type Transport struct { Scheme string Host string PathPrepend string http.RoundTripper }
Transport is a transport for text/html content that replaces URLs in html content with the prefix of the proxy server
func (*Transport) WrappedRoundTripper ¶
func (rt *Transport) WrappedRoundTripper() http.RoundTripper
type UpgradeAwareHandler ¶
type UpgradeAwareHandler struct { // UpgradeRequired will reject non-upgrade connections if true. UpgradeRequired bool // Location is the location of the upstream proxy. It is used as the location to Dial on the upstream server // for upgrade requests unless UseRequestLocationOnUpgrade is true. Location *url.URL // Transport provides an optional round tripper to use to proxy. If nil, the default proxy transport is used Transport http.RoundTripper // UpgradeTransport, if specified, will be used as the backend transport when upgrade requests are provided. // This allows clients to disable HTTP/2. UpgradeTransport http.RoundTripper // WrapTransport indicates whether the provided Transport should be wrapped with default proxy transport behavior (URL rewriting, X-Forwarded-* header setting) WrapTransport bool // InterceptRedirects determines whether the proxy should sniff backend responses for redirects, // following them as necessary. InterceptRedirects bool // UseRequestLocation will use the incoming request URL when talking to the backend server. UseRequestLocation bool // FlushInterval controls how often the standard HTTP proxy will flush content from the upstream. FlushInterval time.Duration // MaxBytesPerSec controls the maximum rate for an upstream connection. No rate is imposed if the value is zero. MaxBytesPerSec int64 // Responder is passed errors that occur while setting up proxying. Responder ErrorResponder }
UpgradeAwareHandler is a handler for proxy requests that may require an upgrade
func NewUpgradeAwareHandler ¶
func NewUpgradeAwareHandler(location *url.URL, transport http.RoundTripper, wrapTransport, upgradeRequired bool, responder ErrorResponder) *UpgradeAwareHandler
NewUpgradeAwareHandler creates a new proxy handler with a default flush interval. Responder is required for returning errors to the caller.
func (*UpgradeAwareHandler) DialForUpgrade ¶
func (*UpgradeAwareHandler) ServeHTTP ¶
func (h *UpgradeAwareHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP handles the proxy request