Chain returns a http.Handler that chains the middleware onion-style around the handler.
(middlewares []MiddlewareFunc, handler http.Handler)
| 22 | |
| 23 | // Chain returns a http.Handler that chains the middleware onion-style around the handler. |
| 24 | func Chain(middlewares []MiddlewareFunc, handler http.Handler) http.Handler { |
| 25 | for i := len(middlewares) - 1; i >= 0; i-- { |
| 26 | handler = middlewares[i](handler) |
| 27 | } |
| 28 | return handler |
| 29 | } |
| 30 | |
| 31 | // Conditional is a middleware that only executes middleware if the condition |
| 32 | // returns true for the request. If the condition returns false, the middleware |
no outgoing calls