forked from mirror/gin
Updates tree.go from httpRouter
This commit is contained in:
parent
8949247b92
commit
20825e7694
13
tree.go
13
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++ {
|
||||
|
|
Loading…
Reference in New Issue