mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 01:57:55 +08:00
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:
commit
9e46bad91c
2
tree.go
2
tree.go
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user