type routingNode … // addPattern adds a pattern and its associated Handler to the tree // at root. func (root *routingNode) addPattern(p *pattern, h Handler) { … } // addSegments adds the given segments to the tree rooted at n. // If there are no segments, then n is a leaf node that holds // the given pattern and handler. func (n *routingNode) addSegments(segs []segment, p *pattern, h Handler) { … } // set sets the pattern and handler for n, which // must be a leaf node. func (n *routingNode) set(p *pattern, h Handler) { … } // addChild adds a child node with the given key to n // if one does not exist, and returns the child. func (n *routingNode) addChild(key string) *routingNode { … } // findChild returns the child of n with the given key, or nil // if there is no child with that key. func (n *routingNode) findChild(key string) *routingNode { … } // match returns the leaf node under root that matches the arguments, and a list // of values for pattern wildcards in the order that the wildcards appear. // For example, if the request path is "/a/b/c" and the pattern is "/{x}/b/{y}", // then the second return value will be []string{"a", "c"}. func (root *routingNode) match(host, method, path string) (*routingNode, []string) { … } // matchMethodAndPath matches the method and path. // Its return values are the same as [routingNode.match]. // The receiver should be a child of the root. func (n *routingNode) matchMethodAndPath(method, path string) (*routingNode, []string) { … } // matchPath matches a path. // Its return values are the same as [routingNode.match]. // matchPath calls itself recursively. The matches argument holds the wildcard matches // found so far. func (n *routingNode) matchPath(path string, matches []string) (*routingNode, []string) { … } // firstSegment splits path into its first segment, and the rest. // The path must begin with "/". // If path consists of only a slash, firstSegment returns ("/", ""). // The segment is returned unescaped, if possible. func firstSegment(path string) (seg, rest string) { … } // matchingMethods adds to methodSet all the methods that would result in a // match if passed to routingNode.match with the given host and path. func (root *routingNode) matchingMethods(host, path string, methodSet map[string]bool) { … } func (n *routingNode) matchingMethodsPath(path string, set map[string]bool) { … }