Save fullPath when node was already added and after moved to a child

This commit is contained in:
isgj 2018-08-09 10:31:14 +02:00
parent 124cea4e8c
commit 6669d5e8e7
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) {