From 20825e7694fe72e8c9df85036951e684a1b61d91 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Thu, 28 Jan 2016 00:14:26 +0100 Subject: [PATCH] Updates tree.go from httpRouter --- tree.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tree.go b/tree.go index c87e0d8..4f2082e 100644 --- a/tree.go +++ b/tree.go @@ -76,9 +76,10 @@ func countParams(path string) uint8 { type nodeType uint8 const ( - static nodeType = 0 - param nodeType = 1 - catchAll nodeType = 2 + static nodeType = iota // default + root + param + catchAll ) type node struct { @@ -238,6 +239,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) { } } else { // Empty tree n.insertChild(numParams, path, fullPath, handlers) + n.nType = root } } @@ -452,6 +454,11 @@ walk: // Outer loop for walking the tree return } + if path == "/" && n.wildChild && n.nType != root { + tsr = true + return + } + // No handle found. Check if a handle for this path + a // trailing slash exists for trailing slash recommendation for i := 0; i < len(n.indices); i++ {