Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChain ¶
func CreateChain(mw []Middleware, finalHandlerFunc http.HandlerFunc) http.HandlerFunc
CreateChain returns a http.HandlerFunc that invokes each middleware in order then the final http.HandlerFunc.
Types ¶
type Middleware ¶
type Middleware func(next http.HandlerFunc) http.HandlerFunc
Middleware functions are invoked each time the server handles a route. The chain of middleware is followed until the final handler is reached. The middleware must call next(w, r) if the middleware does not handle the request.
For example:
middleware := func(next http.HandlerFunc) http.HandlerFunc { return func(writer http.ResponseWriter, request *http.Request) { // Do middleware actions here. // Calling next to invoke the next middleware or request handler. next(writer, request) } }
Click to show internal directories.
Click to hide internal directories.