mux.go
func (mx *Mux) handle(method methodTyp, pattern string, handler http.Handler) *node {
	if len(pattern) == 0 || pattern[0] != '/' {
		panic(fmt.Sprintf("chi: routing pattern must begin with '/' in '%s'", pattern))
	}

	// Build the final routing handler for this Mux.
	if !mx.inline && mx.handler == nil {
		mx.buildRouteHandler()
	}

	// Build endpoint handler with inline middlewares for the route
	var h http.Handler
	if mx.inline {
		mx.handler = http.HandlerFunc(mx.routeHTTP)
		h = Chain(mx.middlewares...).Handler(handler)
	} else {
		h = handler
	}

	// Add the endpoint to the tree and return the node
	return mx.tree.InsertRoute(method, pattern, h)
}
func (mx *Mux) handle(method methodTyp, pattern string, handler http.Handler) *node {
	if len(pattern) == 0 || pattern[0] != '/' {
		panic(fmt.Sprintf("chi: routing pattern must begin with '/' in '%s'", pattern))
	}

	// Build the final routing handler for this Mux.
	if !mx.inline && mx.handler == nil {
		mx.buildRouteHandler()
	}

	// Build endpoint handler with inline middlewares for the route
	var h http.Handler
	if mx.inline {
		mx.handler = http.HandlerFunc(mx.routeHTTP)
		h = Chain(mx.middlewares...).Handler(handler)
	} else {
		h = handler
	}

	// Add the endpoint to the tree and return the node
	return mx.tree.InsertRoute(method, pattern, h)
}
func ( mx * Mux ) handle ( method methodTyp , pattern string , handler http . Handler ) * node { if len ( pattern ) == 0 || pattern [ 0 ] != '/' { panic ( fmt . Sprintf ( " " , pattern ) ) } // Build the final routing handler for this Mux. if ! mx . inline && mx . handler == nil { mx . buildRouteHandler ( ) } // Build endpoint handler with inline middlewares for the route var h http . Handler if mx . inline { mx . handler = http . HandlerFunc ( mx . routeHTTP ) h = Chain ( mx . middlewares ... ) . Handler ( handler ) } else { h = handler } // Add the endpoint to the tree and return the node return mx . tree . InsertRoute ( method , pattern , h ) }
// handle registers a http.Handler in the routing tree for a particular http method
// and routing pattern.
handle registers a http . Handler in the routing tree for a particular http method and routing pattern .