Documentation ¶
Index ¶
- Constants
- func GetCanonizedHost(ctx context.Context) string
- func NegroniRecoverHandler() negroni.Handler
- func NewBackendMetricsMiddleware(registry metrics.Registry, backendName string) negroni.Handler
- func NewCircuitBreakerOptions(expression string) cbreaker.CircuitBreakerOption
- func NewEntryPointMetricsMiddleware(registry metrics.Registry, entryPointName string) negroni.Handler
- func NewReplacePathRegexHandler(regex string, replacement string, handler http.Handler) http.Handler
- func NewSecure(headers *types.Headers) *secure.Secure
- func RecoverHandler(next http.Handler) http.Handler
- type AddPrefix
- type CircuitBreaker
- type Compress
- type EmptyBackendHandler
- type HandlerSwitcher
- type HeaderOptions
- type HeaderStruct
- type IPWhiteLister
- type MetricsRetryListener
- type ReplacePath
- type ReplacePathRegex
- type RequestHost
- type Retry
- type RetryListener
- type RetryListeners
- type Routes
- type Stateful
- type Stats
- type StatsRecorder
- type StripPrefix
- type StripPrefixRegex
Constants ¶
const ForwardedPrefixHeader = "X-Forwarded-Prefix"
ForwardedPrefixHeader is the default header to set prefix
const ReplacedPathHeader = "X-Replaced-Path"
ReplacedPathHeader is the default header to set the old path to
Variables ¶
This section is empty.
Functions ¶
func GetCanonizedHost ¶
GetCanonizedHost plucks the canonized host key from the request of a context that was put through the middleware
func NegroniRecoverHandler ¶ added in v1.3.0
NegroniRecoverHandler recovers from a panic in negroni handlers
func NewBackendMetricsMiddleware ¶ added in v1.6.0
NewBackendMetricsMiddleware creates a new metrics middleware for a Backend.
func NewCircuitBreakerOptions ¶ added in v1.6.0
func NewCircuitBreakerOptions(expression string) cbreaker.CircuitBreakerOption
NewCircuitBreakerOptions returns a new CircuitBreakerOption
func NewEntryPointMetricsMiddleware ¶ added in v1.6.0
func NewEntryPointMetricsMiddleware(registry metrics.Registry, entryPointName string) negroni.Handler
NewEntryPointMetricsMiddleware creates a new metrics middleware for an Entrypoint.
func NewReplacePathRegexHandler ¶ added in v1.5.0
func NewReplacePathRegexHandler(regex string, replacement string, handler http.Handler) http.Handler
NewReplacePathRegexHandler returns a new ReplacePathRegex
Types ¶
type AddPrefix ¶ added in v1.2.0
AddPrefix is a middleware used to add prefix to an URL request
func (*AddPrefix) ServeHTTP ¶ added in v1.2.0
func (s *AddPrefix) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*AddPrefix) SetHandler ¶ added in v1.2.0
SetHandler sets handler
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker holds the oxy circuit breaker.
func NewCircuitBreaker ¶
func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) (*CircuitBreaker, error)
NewCircuitBreaker returns a new CircuitBreaker.
func (*CircuitBreaker) ServeHTTP ¶
func (cb *CircuitBreaker) ServeHTTP(rw http.ResponseWriter, r *http.Request)
type Compress ¶ added in v1.1.0
type Compress struct{}
Compress is a middleware that allows redirection
func (*Compress) ServeHTTP ¶ added in v1.1.0
func (c *Compress) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP is a function used by Negroni
type EmptyBackendHandler ¶ added in v1.4.0
type EmptyBackendHandler struct {
// contains filtered or unexported fields
}
EmptyBackendHandler is a middlware that checks whether the current Backend has at least one active Server in respect to the healthchecks and if this is not the case, it will stop the middleware chain and respond with 503.
func NewEmptyBackendHandler ¶ added in v1.4.0
func NewEmptyBackendHandler(lb healthcheck.BalancerHandler) *EmptyBackendHandler
NewEmptyBackendHandler creates a new EmptyBackendHandler instance.
func (*EmptyBackendHandler) ServeHTTP ¶ added in v1.4.0
func (h *EmptyBackendHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)
ServeHTTP responds with 503 when there is no active Server and otherwise invokes the next handler in the middleware chain.
type HandlerSwitcher ¶
type HandlerSwitcher struct {
// contains filtered or unexported fields
}
HandlerSwitcher allows hot switching of http.ServeMux
func NewHandlerSwitcher ¶
func NewHandlerSwitcher(newHandler *mux.Router) (hs *HandlerSwitcher)
NewHandlerSwitcher builds a new instance of HandlerSwitcher
func (*HandlerSwitcher) GetHandler ¶
func (hs *HandlerSwitcher) GetHandler() (newHandler *mux.Router)
GetHandler returns the current http.ServeMux
func (*HandlerSwitcher) ServeHTTP ¶
func (hs *HandlerSwitcher) ServeHTTP(rw http.ResponseWriter, r *http.Request)
func (*HandlerSwitcher) UpdateHandler ¶
func (hs *HandlerSwitcher) UpdateHandler(newHandler *mux.Router)
UpdateHandler safely updates the current http.ServeMux with a new one
type HeaderOptions ¶ added in v1.4.0
type HeaderOptions struct { // If Custom request headers are set, these will be added to the request CustomRequestHeaders map[string]string // If Custom response headers are set, these will be added to the ResponseWriter CustomResponseHeaders map[string]string }
HeaderOptions is a struct for specifying configuration options for the headers middleware.
type HeaderStruct ¶ added in v1.4.0
type HeaderStruct struct {
// contains filtered or unexported fields
}
HeaderStruct is a middleware that helps setup a few basic security features. A single headerOptions struct can be provided to configure which features should be enabled, and the ability to override a few of the default values.
func NewHeaderFromStruct ¶ added in v1.4.0
func NewHeaderFromStruct(headers *types.Headers) *HeaderStruct
NewHeaderFromStruct constructs a new header instance from supplied frontend header struct.
func (*HeaderStruct) ModifyRequestHeaders ¶ added in v1.5.0
func (s *HeaderStruct) ModifyRequestHeaders(r *http.Request)
ModifyRequestHeaders set or delete request headers
func (*HeaderStruct) ModifyResponseHeaders ¶ added in v1.5.0
func (s *HeaderStruct) ModifyResponseHeaders(res *http.Response) error
ModifyResponseHeaders set or delete response headers
func (*HeaderStruct) ServeHTTP ¶ added in v1.4.0
func (s *HeaderStruct) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type IPWhiteLister ¶ added in v1.4.0
type IPWhiteLister struct {
// contains filtered or unexported fields
}
IPWhiteLister is a middleware that provides Checks of the Requesting IP against a set of Whitelists
func NewIPWhiteLister ¶ added in v1.6.0
func NewIPWhiteLister(whiteList []string, useXForwardedFor bool) (*IPWhiteLister, error)
NewIPWhiteLister builds a new IPWhiteLister given a list of CIDR-Strings to whitelist
func (*IPWhiteLister) ServeHTTP ¶ added in v1.4.0
func (wl *IPWhiteLister) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type MetricsRetryListener ¶ added in v1.4.0
type MetricsRetryListener struct {
// contains filtered or unexported fields
}
MetricsRetryListener is an implementation of the RetryListener interface to record RequestMetrics about retry attempts.
type ReplacePath ¶ added in v1.3.0
ReplacePath is a middleware used to replace the path of a URL request
func (*ReplacePath) ServeHTTP ¶ added in v1.3.0
func (s *ReplacePath) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ReplacePathRegex ¶ added in v1.5.0
ReplacePathRegex is a middleware used to replace the path of a URL request with a regular expression
func (*ReplacePathRegex) ServeHTTP ¶ added in v1.5.0
func (s *ReplacePathRegex) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RequestHost ¶
type RequestHost struct{}
RequestHost is the struct for the middleware that adds the CanonicalDomain of the request Host into a context for later use.
func (*RequestHost) ServeHTTP ¶
func (rh *RequestHost) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type Retry ¶
type Retry struct {
// contains filtered or unexported fields
}
Retry is a middleware that retries requests
type RetryListener ¶ added in v1.4.0
type RetryListener interface { // Retried will be called when a retry happens, with the request attempt passed to it. // For the first retry this will be attempt 2. Retried(req *http.Request, attempt int) }
RetryListener is used to inform about retry attempts.
func NewMetricsRetryListener ¶ added in v1.4.0
func NewMetricsRetryListener(retryMetrics retryMetrics, backendName string) RetryListener
NewMetricsRetryListener instantiates a MetricsRetryListener with the given retryMetrics.
type RetryListeners ¶ added in v1.4.0
type RetryListeners []RetryListener
RetryListeners is a convenience type to construct a list of RetryListener and notify each of them about a retry attempt.
type Routes ¶
type Routes struct {
// contains filtered or unexported fields
}
Routes holds the gorilla mux routes (for the API & co).
func (*Routes) ServeHTTP ¶
func (router *Routes) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type Stateful ¶ added in v1.3.0
type Stateful interface { http.ResponseWriter http.Hijacker http.Flusher http.CloseNotifier }
Stateful interface groups all http interfaces that must be implemented by a stateful middleware (ie: recorders)
type Stats ¶ added in v1.2.0
type Stats struct {
RecentErrors []*statsError `json:"recent_errors"`
}
Stats includes all of the stats gathered by the recorder.
type StatsRecorder ¶ added in v1.2.0
type StatsRecorder struct {
// contains filtered or unexported fields
}
StatsRecorder is an optional middleware that records more details statistics about requests and how they are processed. This currently consists of recent requests that have caused errors (4xx and 5xx status codes), making it easy to pinpoint problems.
func NewStatsRecorder ¶ added in v1.2.0
func NewStatsRecorder(numRecentErrors int) *StatsRecorder
NewStatsRecorder returns a new StatsRecorder
func (*StatsRecorder) Data ¶ added in v1.2.0
func (s *StatsRecorder) Data() *Stats
Data returns a copy of the statistics that have been gathered.
func (*StatsRecorder) ServeHTTP ¶ added in v1.2.0
func (s *StatsRecorder) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP silently extracts information from the request and response as it is processed. If the response is 4xx or 5xx, add it to the list of 10 most recent errors.
type StripPrefix ¶
StripPrefix is a middleware used to strip prefix from an URL request
func (*StripPrefix) ServeHTTP ¶
func (s *StripPrefix) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*StripPrefix) SetHandler ¶
func (s *StripPrefix) SetHandler(Handler http.Handler)
SetHandler sets handler
type StripPrefixRegex ¶ added in v1.3.0
StripPrefixRegex is a middleware used to strip prefix from an URL request
func NewStripPrefixRegex ¶ added in v1.3.0
func NewStripPrefixRegex(handler http.Handler, prefixes []string) *StripPrefixRegex
NewStripPrefixRegex builds a new StripPrefixRegex given a handler and prefixes
func (*StripPrefixRegex) ServeHTTP ¶ added in v1.3.0
func (s *StripPrefixRegex) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*StripPrefixRegex) SetHandler ¶ added in v1.3.0
func (s *StripPrefixRegex) SetHandler(Handler http.Handler)
SetHandler sets handler