Documentation ¶
Overview ¶
Package httpmw supports creating middleware chains for HTTP handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface {
Log(...interface{}) error
}
Logger defines the Log method that is used to log structured data, in tuples of alternating keys/values. The go-kit logger satisfies this interface (github.com/go-kit/kit/log).
type PrintfLogger ¶
type PrintfLogger func(string, ...interface{})
PrintfLogger is an adapter to use Printf-style functions as a Logger in the middlewares that accept one. For example, the stdlib's log.Printf function can be used via this adapter.
func (PrintfLogger) Log ¶
func (fn PrintfLogger) Log(args ...interface{}) error
Log implements Logger for the PrintfLogger function adapter.
type StatusHandler ¶
type StatusHandler int
StatusHandler is an integer that handles HTTP requests by writing itself as status code. No body is sent.
func (StatusHandler) ServeHTTP ¶
func (s StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for the StatusHandler.
type WrapperFunc ¶
WrapperFunc is a function type that implements the Wrapper interface, useful to adapt middleware from other packages.
Directories ¶
Path | Synopsis |
---|---|
Package augmentedrw implements a middleware that replaces the standard http.ResponseWriter with one that records the Size and Status of the response.
|
Package augmentedrw implements a middleware that replaces the standard http.ResponseWriter with one that records the Size and Status of the response. |
Package basicauth implements a basic authentication middleware.
|
Package basicauth implements a basic authentication middleware. |
Package bodylimit implements an HTTP middleware that limits the number of bytes that can be read from the request body.
|
Package bodylimit implements an HTTP middleware that limits the number of bytes that can be read from the request body. |
Package cleanpath implements a middleware that cleans the requested path to a canonical form.
|
Package cleanpath implements a middleware that cleans the requested path to a canonical form. |
Package cors implements a CORS middleware and a handler for OPTIONS requests.
|
Package cors implements a CORS middleware and a handler for OPTIONS requests. |
Package headers defines a middleware that adds static headers to the requests.
|
Package headers defines a middleware that adds static headers to the requests. |
Package logrequest implements a middleware that logs requests.
|
Package logrequest implements a middleware that logs requests. |
Package ratelimit implements a rate limiter middleware handler.
|
Package ratelimit implements a rate limiter middleware handler. |
Package recover implements a middleware that recovers from panics.
|
Package recover implements a middleware that recovers from panics. |
Package remoteip implements a middleware that extracts the effective remote client IP address and sets it on the request's RemoteAddr field.
|
Package remoteip implements a middleware that extracts the effective remote client IP address and sets it on the request's RemoteAddr field. |
Package requestid implements a middleware that generates a random request ID.
|
Package requestid implements a middleware that generates a random request ID. |
Package stripprefix implements a middleware handler that strips a prefix from the request URL's Path.
|
Package stripprefix implements a middleware handler that strips a prefix from the request URL's Path. |
Package timeout implements a middleware that returns a 503 error if the request takes too long to execute.
|
Package timeout implements a middleware that returns a 503 error if the request takes too long to execute. |