Documentation
¶
Index ¶
Constants ¶
const ( AuthorizationHeader = "Authorization" ProxyAuthorizationHeader = "Proxy-Authorization" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicAuth ¶
type BasicAuth struct {
// contains filtered or unexported fields
}
BasicAuth exposes common Basic Authentication functionalities from the standard library, and allows to customize the Authentication header. This is useful when you want to use Basic Authentication for a proxy.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization
func NewBasicAuth ¶
func NewBasicAuth() *BasicAuth
func NewProxyBasicAuth ¶
func NewProxyBasicAuth() *BasicAuth
func (*BasicAuth) AuthenticatedRequest ¶
AuthenticatedRequest parses the provided HTTP request for Basic Authentication credentials and returns true if the provided credentials match the expected username and password. Returns false if the request is unauthenticated. Uses constant-time comparison in order to mitigate timing attacks.
func (*BasicAuth) BasicAuth ¶
BasicAuth returns the username and password provided in the request's authorization header, if the request uses HTTP Basic Authentication. See RFC 2617, Section 2.
func (*BasicAuth) Wrap ¶
Wrap wraps the provided http.Handler with basic authentication. If header is Proxy-Authorization and the request is not authenticated, the handler is not called and a 407 Proxy Authentication Required is returned. Otherwise, if the request is not authenticated, the handler is not called and a 401 Unauthorized is returned. The provided username and password are used to authenticate the request.
type Logger ¶
type Logger func(e LogEntry)
func (Logger) WrapRoundTripper ¶ added in v1.1.1
func (l Logger) WrapRoundTripper(rt http.RoundTripper) http.RoundTripper
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus is a middleware that collects metrics about the HTTP requests and responses. Unlike the promhttp.InstrumentHandler* chaining, this middleware creates only one delegator per request. It partitions the metrics by HTTP status code, HTTP method, destination host name and source IP.
func NewPrometheus ¶
func NewPrometheus(r prometheus.Registerer, namespace string, opts ...PrometheusOpt) *Prometheus
func (*Prometheus) ReadRequest ¶ added in v1.2.0
func (p *Prometheus) ReadRequest(req *http.Request)
func (*Prometheus) WroteResponse ¶ added in v1.2.0
func (p *Prometheus) WroteResponse(res *http.Response)
type PrometheusLabeler ¶ added in v1.3.0
type PrometheusOpt ¶ added in v1.3.0
type PrometheusOpt func(*Prometheus)
func WithCustomLabeler ¶ added in v1.3.0
func WithCustomLabeler(label string, labeler PrometheusLabeler) PrometheusOpt