pratiks
9/16/2017 - 2:35 PM

Go httpServer - Mux

Inner Workings of the Go net/http lib.

 - Mux is simple HTTP route multiplexer that parses the request path
 - records any url params and executes an end handler 
 - implements http.Handler
 

type Mux struct {
	// The radix trie router
	tree *node

	// The middleware stack
	middlewares []func(http.Handler) http.Handler

	// Controls the behaviour of middleware chain generation when a mux
	// is registered as an inline group inside another mux.
	inline bool

	// The computed mux handler made of the chained middleware stack and
	// the tree router
	handler http.Handler

	// Routing context pool
	pool sync.Pool

	// Custom route not found handler
	notFoundHandler http.HandlerFunc

	// Custom method not allowed handler
	methodNotAllowedHandler http.HandlerFunc
}