httputil

package
v1.7.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
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

func ComputeStatusCode(err error) int

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

func JoinURLPath(a, b *url.URL) (path, rawpath string)

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

func SetNotAppendXFF(ctx context.Context) context.Context

SetNotAppendXFF indicates xff should not be appended.

func ShouldNotAppendXFF

func ShouldNotAppendXFF(ctx context.Context) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL