middlewares

package
v1.3.0-rc2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2017 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const ReplacedPathHeader = "X-Replaced-Path"

ReplacedPathHeader is the default header to set the old path to

Variables

This section is empty.

Functions

func NegroniRecoverHandler added in v1.3.0

func NegroniRecoverHandler() negroni.Handler

NegroniRecoverHandler recovers from a panic in negroni handlers

func RecoverHandler added in v1.3.0

func RecoverHandler(next http.Handler) http.Handler

RecoverHandler recovers from a panic in http handlers

func SetBackend2FrontendMap

func SetBackend2FrontendMap(newMap *map[string]string)

SetBackend2FrontendMap is called by server.go to set up frontend translation

Types

type AddPrefix added in v1.2.3

type AddPrefix struct {
	Handler http.Handler
	Prefix  string
}

AddPrefix is a middleware used to add prefix to an URL request

func (*AddPrefix) ServeHTTP added in v1.2.3

func (s *AddPrefix) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*AddPrefix) SetHandler added in v1.2.3

func (s *AddPrefix) SetHandler(Handler http.Handler)

SetHandler sets handler

type Authenticator added in v1.2.3

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator is a middleware that provides HTTP basic and digest authentication

func NewAuthenticator added in v1.2.3

func NewAuthenticator(authConfig *types.Auth) (*Authenticator, error)

NewAuthenticator builds a new Autenticator given a config

func (*Authenticator) ServeHTTP added in v1.2.3

func (a *Authenticator) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

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, next http.HandlerFunc)

type Compress added in v1.2.3

type Compress struct {
}

Compress is a middleware that allows redirections

func (*Compress) ServeHTTP added in v1.2.3

func (c *Compress) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

ServerHTTP is a function used by negroni

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 Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger writes each request and its response to the access log. It gets some information from the logInfoResponseWriter set up by previous middleware.

func NewLogger

func NewLogger(file string) *Logger

NewLogger returns a new Logger instance.

func (*Logger) Close

func (l *Logger) Close()

Close closes the Logger (i.e. the file).

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Metrics added in v1.2.3

type Metrics interface {
	// contains filtered or unexported methods
}

Metrics is an Interface that must be satisfied by any system that wants to expose and monitor metrics

type MetricsWrapper added in v1.2.3

type MetricsWrapper struct {
	Impl Metrics
}

MetricsWrapper is a Negroni compatible Handler which relies on a given Metrics implementation to expose and monitor Traefik metrics

func NewMetricsWrapper added in v1.2.3

func NewMetricsWrapper(impl Metrics) *MetricsWrapper

NewMetricsWrapper return a MetricsWrapper struct with a given Metrics implementation e.g Prometheuss

func (*MetricsWrapper) Handler added in v1.2.3

func (m *MetricsWrapper) Handler() http.Handler

Handler is the chance for the Metrics implementation to expose its metrics on a server endpoint

func (*MetricsWrapper) ServeHTTP added in v1.2.3

func (m *MetricsWrapper) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Prometheus added in v1.2.3

type Prometheus struct {
	// contains filtered or unexported fields
}

Prometheus is an Implementation for Metrics that exposes prometheus metrics for the latency and the number of requests partitioned by status code and method.

func NewPrometheus added in v1.2.3

func NewPrometheus(name string, config *types.Prometheus) *Prometheus

NewPrometheus returns a new prometheus Metrics implementation.

type ReplacePath added in v1.3.0

type ReplacePath struct {
	Handler http.Handler
	Path    string
}

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 ResponseRecorder

type ResponseRecorder struct {
	Code      int           // the HTTP response code from WriteHeader
	HeaderMap http.Header   // the HTTP response headers
	Body      *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to
	// contains filtered or unexported fields
}

ResponseRecorder is an implementation of http.ResponseWriter that records its mutations for later inspection in tests.

func NewRecorder

func NewRecorder() *ResponseRecorder

NewRecorder returns an initialized ResponseRecorder.

func (*ResponseRecorder) CloseNotify added in v1.2.3

func (rw *ResponseRecorder) CloseNotify() <-chan bool

CloseNotify returns a channel that receives at most a single value (true) when the client connection has gone away.

func (*ResponseRecorder) Flush added in v1.2.3

func (rw *ResponseRecorder) Flush()

Flush sends any buffered data to the client.

func (*ResponseRecorder) Header

func (rw *ResponseRecorder) Header() http.Header

Header returns the response headers.

func (*ResponseRecorder) Hijack

func (rw *ResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack hijacks the connection

func (*ResponseRecorder) Write

func (rw *ResponseRecorder) Write(buf []byte) (int, error)

Write always succeeds and writes to rw.Body, if not nil.

func (*ResponseRecorder) WriteHeader

func (rw *ResponseRecorder) WriteHeader(code int)

WriteHeader sets rw.Code.

type Retry

type Retry struct {
	// contains filtered or unexported fields
}

Retry is a middleware that retries requests

func NewRetry

func NewRetry(attempts int, next http.Handler) *Retry

NewRetry returns a new Retry instance

func (*Retry) ServeHTTP

func (retry *Retry) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Rewrite

type Rewrite struct {
	// contains filtered or unexported fields
}

Rewrite is a middleware that allows redirections

func NewRewrite

func NewRewrite(regex, replacement string, redirect bool) (*Rewrite, error)

NewRewrite creates a Rewrite middleware

func (*Rewrite) ServeHTTP

func (rewrite *Rewrite) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Routes

type Routes struct {
	// contains filtered or unexported fields
}

Routes holds the gorilla mux routes (for the API & co).

func NewRoutes

func NewRoutes(router *mux.Router) *Routes

NewRoutes return a Routes based on the given router.

func (*Routes) ServeHTTP

func (router *Routes) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type SaveBackend

type SaveBackend struct {
	// contains filtered or unexported fields
}

SaveBackend sends the backend name to the logger.

func NewSaveBackend

func NewSaveBackend(next http.Handler) *SaveBackend

NewSaveBackend creates a SaveBackend

func (*SaveBackend) ServeHTTP

func (sb *SaveBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Stateful added in v1.3.0

Stateful interface groups all http interfaces that must be implemented by a stateful middleware (ie: recorders)

type Stats added in v1.2.3

type Stats struct {
	RecentErrors []*statsError `json:"recent_errors"`
}

Stats includes all of the stats gathered by the recorder.

type StatsRecorder added in v1.2.3

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.3

func NewStatsRecorder(numRecentErrors int) *StatsRecorder

NewStatsRecorder returns a new StatsRecorder

func (*StatsRecorder) Data added in v1.2.3

func (s *StatsRecorder) Data() *Stats

Data returns a copy of the statistics that have been gathered.

func (*StatsRecorder) ServeHTTP added in v1.2.3

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

type StripPrefix struct {
	Handler  http.Handler
	Prefixes []string
}

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

type StripPrefixRegex struct {
	Handler http.Handler
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

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