Merge pull request #1 from isgj/master

Save fullPath when node was already added and after moved to a child
This commit is contained in:
youngbloood 2018-08-09 17:08:58 +08:00 committed by GitHub
commit 9e46bad91c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -155,6 +155,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
children: n.children,
handlers: n.handlers,
priority: n.priority - 1,
fullPath: n.fullPath,
}
// Update maxParams (max of all children)
@ -236,6 +237,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
panic("handlers are already registered for path '" + fullPath + "'")
}
n.handlers = handlers
n.fullPath = fullPath
}
return
}

View File

@ -33,7 +33,7 @@ func checkRequests(t *testing.T, tree *node, requests testRequests, unescapes ..
}
for _, request := range requests {
handler, ps, _, _ := tree.getValue(request.path, nil, unescape)
handler, ps, rp, _ := tree.getValue(request.path, nil, unescape)
if handler == nil {
if !request.nilHandler {
@ -46,6 +46,9 @@ func checkRequests(t *testing.T, tree *node, requests testRequests, unescapes ..
if fakeHandlerValue != request.route {
t.Errorf("handle mismatch for route '%s': Wrong handle (%s != %s)", request.path, fakeHandlerValue, request.route)
}
if rp != request.route {
t.Errorf("full path mismatch, expected: \"%s\" got: \"%s\"", request.route, rp)
}
}
if !reflect.DeepEqual(ps, request.ps) {