Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,28 @@ func (n *node) incrementChildPrio(pos int) int {
return newPos
}

func (n *node) compareEmptyTree(path string, fullPath string, handlers HandlersChain) {
if len(n.path) == 0 && len(n.children) == 0 {
n.insertChild(path, fullPath, handlers)
n.nType = root
return
}
}

// addRoute adds a node with the given handle to the path.
// Not concurrency-safe!
func (n *node) addRoute(path string, handlers HandlersChain) {
fullPath := path
n.priority++

// Empty tree
if len(n.path) == 0 && len(n.children) == 0 {
n.insertChild(path, fullPath, handlers)
n.nType = root
return
}
// // Empty tree
// if len(n.path) == 0 && len(n.children) == 0 {
// n.insertChild(path, fullPath, handlers)
// n.nType = root
// return
// }

n.compareEmptyTree(path, fullPath, handlers)

parentFullPathIndex := 0

Expand Down
Loading