Documentation
¶
Index ¶
- Constants
- func ComputeStatusCode(err error) int
- func ErrorHandler(w http.ResponseWriter, req *http.Request, err error)
- func ErrorHandlerWithContext(ctx context.Context, w http.ResponseWriter, err error)
- func JoinURLPath(a, b *url.URL) (path, rawpath string)
- func SetNotAppendXFF(ctx context.Context) context.Context
- func ShouldNotAppendXFF(ctx context.Context) bool
- type ProxyBuilder
- type TransportManager
Constants ¶
const ( // StatusClientClosedRequest non-standard HTTP status code for client disconnection. StatusClientClosedRequest = 499 // StatusClientClosedRequestText non-standard HTTP status for client disconnection. StatusClientClosedRequestText = "Client Closed Request" )
Variables ¶
This section is empty.
Functions ¶
func ComputeStatusCode ¶
ComputeStatusCode computes the HTTP status code according to the given error.
func ErrorHandler ¶
func ErrorHandler(w http.ResponseWriter, req *http.Request, err error)
ErrorHandler is the http.Handler called when something goes wrong when forwarding the request.
func ErrorHandlerWithContext ¶
func ErrorHandlerWithContext(ctx context.Context, w http.ResponseWriter, err error)
ErrorHandlerWithContext is the http.Handler called when something goes wrong when forwarding the request.
func JoinURLPath ¶
JoinURLPath computes the joined path and raw path of the given URLs. From https://github.com/golang/go/blob/b521ebb55a9b26c8824b219376c7f91f7cda6ec2/src/net/http/httputil/reverseproxy.go#L221
func SetNotAppendXFF ¶
SetNotAppendXFF indicates xff should not be appended.
func ShouldNotAppendXFF ¶
ShouldNotAppendXFF returns whether X-Forwarded-For should not be appended.
Types ¶
type ProxyBuilder ¶
type ProxyBuilder struct {
// contains filtered or unexported fields
}
ProxyBuilder handles the http.RoundTripper for httputil reverse proxies.
func NewProxyBuilder ¶
func NewProxyBuilder(transportManager TransportManager, semConvMetricsRegistry *metrics.SemConvMetricsRegistry) *ProxyBuilder
NewProxyBuilder creates a new ProxyBuilder.
func (*ProxyBuilder) Build ¶
func (r *ProxyBuilder) Build(cfgName string, targetURL *url.URL, passHostHeader, preservePath bool, flushInterval time.Duration) (http.Handler, error)
Build builds a new httputil.ReverseProxy with the given configuration.
func (*ProxyBuilder) Update ¶
func (r *ProxyBuilder) Update(_ map[string]*dynamic.ServersTransport)
Update does nothing.
type TransportManager ¶
type TransportManager interface {
Get(name string) (*dynamic.ServersTransport, error)
GetRoundTripper(name string) (http.RoundTripper, error)
GetTLSConfig(name string) (*tls.Config, error)
}
TransportManager manages transport used for backend communications.