routetree.go
func (n *routeNode) insertChild(nn *routeNode) *routeNode {
	if child := n.findChild(nn); child != nil {
		return child
	}

	if n.paramChild != nil && nn.paramNode {
		// only allow one param child, unique param name
		if n.paramChild.paramName != nn.paramName {
			panic("Param name must be same for")
		}
		return n.paramChild
	}
	if nn.paramNode {
		n.paramChild = nn
	} else {
		n.children = append(n.children, nn)
	}
	return nn
}
func (n *routeNode) insertChild(nn *routeNode) *routeNode {
	if child := n.findChild(nn); child != nil {
		return child
	}

	if n.paramChild != nil && nn.paramNode {
		// only allow one param child, unique param name
		if n.paramChild.paramName != nn.paramName {
			panic("Param name must be same for")
		}
		return n.paramChild
	}
	if nn.paramNode {
		n.paramChild = nn
	} else {
		n.children = append(n.children, nn)
	}
	return nn
}
func ( n * routeNode ) insertChild ( nn * routeNode ) * routeNode { if child := n . findChild ( nn ) ; child != nil { return child } if n . paramChild != nil && nn . paramNode { // only allow one param child, unique param name if n . paramChild . paramName != nn . paramName { panic ( " " ) } return n . paramChild } if nn . paramNode { n . paramChild = nn } else { n . children = append ( n . children , nn ) } return nn }
// insertChild registers given node in the route node tree
// If there is already a similar node it will not insert new node
// The returned node is always the registered one ie either
// newly registered or the old one
insertChild registers given node in the route node tree If there is already a similar node it will not insert new node The returned node is always the registered one ie either newly registered or the old one