Documentation ¶
Overview ¶
Package mid has extremely mid middleware helpers.
Index ¶
- type Controller
- type Middleware
- type Stack
- func (stack Stack) Clone() Stack
- func (stack Stack) Controller(c Controller) http.Handler
- func (stack Stack) Handler(h http.Handler) http.Handler
- func (stack Stack) HandlerFunc(f http.HandlerFunc) http.Handler
- func (stack *Stack) Push(mw ...Middleware)
- func (stack *Stack) PushIf(cond bool, mw ...Middleware)
- func (stack *Stack) With(mw ...Middleware) Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
Controller implements the pattern in https://choly.ca/post/go-experiments-with-handler/
func (Controller) ServeHTTP ¶
func (c Controller) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Middleware ¶
Middleware is any function that wraps an http.Handler returning a new http.Handler.
type Stack ¶
type Stack []Middleware
Stack is a slice of Middleware.
func (Stack) Controller ¶
func (stack Stack) Controller(c Controller) http.Handler
Controller builds an http.Handler that applies all the middleware in the stack before calling c.
func (Stack) Handler ¶
Handler builds an http.Handler that applies all the middleware in the stack before calling h.
Handler is itself a Middleware.
func (Stack) HandlerFunc ¶
func (stack Stack) HandlerFunc(f http.HandlerFunc) http.Handler
HandlerFunc builds an http.Handler that applies all the middleware in the stack before calling f.
func (*Stack) Push ¶
func (stack *Stack) Push(mw ...Middleware)
Push adds Middleware to end of the stack.
func (*Stack) PushIf ¶
func (stack *Stack) PushIf(cond bool, mw ...Middleware)
PushIf adds Middleware to end of the stack if cond is true.
func (*Stack) With ¶
func (stack *Stack) With(mw ...Middleware) Stack
With clones the stack and pushes to the cloned stack.