Mux is a simple HTTP route multiplexer that parses a request path, records any URL params, and executes an end handler. It implements the http.Handler interface and is friendly with the standard library. Mux is designed to be fast, minimal and offer a powerful API for building modular and composabl
| 19 | // particularly useful for writing large REST API services that break a handler |
| 20 | // into many smaller parts composed of middlewares and end handlers. |
| 21 | type Mux struct { |
| 22 | // The computed mux handler made of the chained middleware stack and |
| 23 | // the tree router |
| 24 | handler http.Handler |
| 25 | |
| 26 | // The radix trie router |
| 27 | tree *node |
| 28 | |
| 29 | // Custom method not allowed handler |
| 30 | methodNotAllowedHandler http.HandlerFunc |
| 31 | |
| 32 | // A reference to the parent mux used by subrouters when mounting |
| 33 | // to a parent mux |
| 34 | parent *Mux |
| 35 | |
| 36 | // Routing context pool |
| 37 | pool *sync.Pool |
| 38 | |
| 39 | // Custom route not found handler |
| 40 | notFoundHandler http.HandlerFunc |
| 41 | |
| 42 | // The middleware stack |
| 43 | middlewares []func(http.Handler) http.Handler |
| 44 | |
| 45 | // Controls the behaviour of middleware chain generation when a mux |
| 46 | // is registered as an inline group inside another mux. |
| 47 | inline bool |
| 48 | } |
| 49 | |
| 50 | // NewMux returns a newly initialized Mux object that implements the Router |
| 51 | // interface. |
nothing calls this directly
no outgoing calls
no test coverage detected