httputil

package
v0.0.0-...-d8b0a59 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) *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