# Functions
BodyRewindableWithFile returns a Request suitable for use with Redirect, like 307 redirect for PUT or POST.
No description provided by the author
ClientIP implements a best effort algorithm to return the real client IP, it parses X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy.
go:linkname CloneMultipartFileHeader net/http.cloneMultipartFileHeader.
go:linkname CloneMultipartForm net/http.cloneMultipartForm.
CloneOrMakeHeader invokes Header.Clone but if the result is nil, it'll instead make and return a non-nil Header.
CloneTLSConfig returns a shallow clone of cfg, or a new zero tls.Config if cfg is nil.
go:linkname CloneURL net/http.cloneURL.
go:linkname CloneURLValues net/http.cloneURLValues.
ContentType implements the algorithm described at https://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data.
DoesRequestSatisfyTlsTermination returns whether the request fulfills tls's constraints, https, path matches any whitelisted paths or ip inclued by any cidr whitelistedPath is http path that does not need to be checked allowedTLSCIDR is the network includes ip.
DoJson the same as HttpDo, but bind with json.
DoJsonWithBackoff the same as DoWithBackoff, but bind with json.
DoWithBackoff will retry by exponential backoff if failed.
FromHTTPContext parse request id from gin.Context query | header | post form | context 从请求中提取request-id.
No description provided by the author
GetProxySchemeAndHost extracts the host and used protocol (either HTTP or HTTPS) from the given request.
No description provided by the author
No description provided by the author
No description provided by the author
HostFuncFromContext builds a host function from the given string, which should represent a Target that can be used as a host.
NewClient returns a http client wrapper behaves like http.Client, sends HTTP Request to target by proxy url with Host replaced by proxyTarget
u is the original url to send HTTP request, empty usually.
NewClientWithProxy returns a Client with http.Client with proxy set by resolver.Host TargetUrl is proxy's url, like socks5://127.0.0.1:8080 Host is proxy's addr, replace the HOST in TargetUrl if not empty.
NewClientWithTarget returns a Client with http.Client and host replaced by resolver.Host target is the resolver to resolve Host to send HTTP request, that is replacing host in url(NOT HOST in http header) by address resolved by Host.
No description provided by the author
No description provided by the author
NewRecordResponseWriter creates a ResponseWriter that is a wrapper around [http.ResponseWriter] that provides extra information about the response.
NewResponseWriterDelegator creates a ResponseWriter that is a wrapper around [http.ResponseWriter] that provides extra information about the response.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ProxyFuncFromContextOrEnvironment builds a proxy function from the given string, which should represent a Target that can be used as a proxy.
ProxyFuncWithTargetOrDefault builds a proxy function from the given string, which should represent a Target that can be used as a proxy.
No description provided by the author
Recover and dump HTTP request if broken pipe.
RecoveryClientInterceptor returns a new client interceptors with recovery from panic.
RecoveryServerInterceptor returns a new server interceptors with recovery from panic.
RejectInsecureServerInterceptor returns a new server interceptor with tls check.
RejectInsecureWithAllowedTlsCidrs specifies whether to allow any request which client or proxy's ip included a cidr is a CIDR notation IP address and prefix length, like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291.
RejectInsecureWithErrorLog specifies an optional logger for errors.
RejectInsecureWithForceHttp specifies whether to allow any request, as a shortcut circuit.
RejectInsecureWithWhitelistedPaths specifies whether to allow any request which http path matches.
ReplaceHttpRequestBody replace Body and recalculate ContentLength If ContentLength should not be recalculated, save and restore it after ReplaceHttpRequestBody.
StripPrefix returns a handler that serves HTTP requests by removing the given prefix from the request URL's Path and invoking the handler h.
No description provided by the author
No description provided by the author
RequestWithBodyRewindable returns a Request suitable for use with Redirect, like 307 redirect for PUT or POST.
RequestWithHostTarget replace Host in url.Url by resolver.Host replace Host in req if replaceHostInRequest is true.
RequestWithProxyTarget returns a shallow copy of r with its context changed to ctx, TargetUrl and Host inside.
ResolveProxyUrl resolves a URI reference to a URI from a URI u and origin [scheme,host] forwarded behind proxy in r.
RetryAfter tries to parse Retry-After response header when a http.StatusTooManyRequests (HTTP Code 429) is found in the resp parameter.
RoundTripperWithBackoff wraps http.RoundTripper retryable by backoff.
RoundTripperWithTarget wraps http.RoundTripper with request url replaced by Target resolved by resolver.
ServeContent replies to the request using the content in the provided Reader.
ServerWithDefaults patches a http.Server based on a best practice configuration from Cloudflare: https://blog.cloudflare.com/exposing-go-on-the-internet/
You can override the defaults by mutating the Default* variables exposed by this package.
SetInOutMetadata injects requestIDs in req|resp's Header and context 将request-id追加注入请求|响应头及context中.
TransportWithProxyTarget wraps http.RoundTripper with request url replaced by Target resolved by resolver.
WarnText returns a text for the HTTP warn code.
WithDoWithBackoffOptionChainUnaryInterceptor returns a DoWithBackoffOption that specifies the chained interceptor for http clients.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WithDoWithBackoffOptionProxy returns a DoWithBackoffOption.
No description provided by the author
WithDoWithBackoffOptionRoundTripper returns a DoWithBackoffOption.
WithDoWithBackoffOptionTarget returns a DoWithBackoffOption.
No description provided by the author
WithResponseWriterDelegatorObserveWriteHeader sets observeWriteHeader in responseWriterDelegator.
# Constants
RFC 7234, 5.5.3.
RFC 7234, 5.5.4.
RFC 7234, 5.5.7.
RFC 7234, 5.5.5.
RFC 7234, 5.5.1.
RFC 7234, 5.5.2.
RFC 7234, 5.5.6.
# Variables
DefaultCipherSuites defines the recommended cipher suites for modern TLS.
No description provided by the author
DefaultClientWithDynamicHost is the default Client with DefaultTransportWithDynamicHost.
DefaultClientWithDynamicHostAndProxy is the default Client with DefaultTransportWithDynamicHostAndProxy.
DefaultClientWithDynamicProxy is the default Client with DefaultTransportWithDynamicProxy.
DefaultCurvePreferences defines the recommended elliptic curves for modern TLS.
DefaultIdleTimeout sets the maximum amount of time a Keep-Alive connection can remain idle before being recycled (120s).
DefaultMinVersion defines the recommended minimum version to use for the TLS protocol (1.2).
DefaultReadTimeout sets the maximum time a client has to fully stream a request (5s).
No description provided by the author
DefaultTransportWithDynamicHost is the default implementation of Transport and is used by DefaultClientWithDynamicHost.
DefaultTransportWithDynamicHostAndProxy is the default implementation of Transport and is used by DefaultClientWithDynamicHostAndProxy.
DefaultTransportWithDynamicProxy is the default implementation of Transport and is used by DefaultClientWithDynamicProxy.
DefaultWriteTimeout sets the maximum amount of time a handler has to fully process a request (10s).
DefaultXRequestIDKey is metadata key name for request ID.
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
EmptyDoWithBackoffOption does not alter the configuration.
EmptyHandlerInterceptorChainOption does not alter the configuration.
EmptyRejectInsecureOption does not alter the configuration.
EmptyResponseWriterDelegatorOption does not alter the configuration.
HandlerInterceptorChain interface that allows for customized handler execution chains.
No description provided by the author
# Interfaces
A DoWithBackoffOption sets options.
HandlerDecorator is an interface representing the ability to decorate or wrap a http.Handler.
A HandlerInterceptorChainOption sets options.
A RejectInsecureOption sets options.
A ResponseWriterDelegatorOption sets options.
RoundTripDecorator is an interface representing the ability to decorate or wrap a http.RoundTripper.
# Type aliases
ClientInterceptor intercepts the execution of a HTTP on the client.
ClientInvoker is called by ClientInterceptor to complete RPCs.
DoRetryHandler send an HTTP request with retry seq and returns an HTTP response, following policy (such as redirects, cookies, auth) as configured on the client.
DoWithBackoffOptionFunc wraps a function that modifies doWithBackoff into an implementation of the DoWithBackoffOption interface.
The HandlerDecoratorFunc type is an adapter to allow the use of ordinary functions as HTTP handler decorators.
HandlerDecorators defines a HandlerDecorator slice.
HandlerInterceptorChainOptionFunc wraps a function that modifies HandlerInterceptorChain into an implementation of the HandlerInterceptorChainOption interface.
RejectInsecureOptionFunc wraps a function that modifies rejectInsecure into an implementation of the RejectInsecureOption interface.
ResponseWriterDelegatorOptionFunc wraps a function that modifies responseWriterDelegator into an implementation of the ResponseWriterDelegatorOption interface.
No description provided by the author
RoundTripDecorators defines a RoundTripDecorator slice.
RoundTripFunc is an adapter to allow the use of ordinary functions as HTTP Transport handlers.