mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 10:02:10 +08:00
Save fullPath when node was already added and after moved to a child
This commit is contained in:
parent
124cea4e8c
commit
6669d5e8e7
2
tree.go
2
tree.go
@ -155,6 +155,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
|
|||||||
children: n.children,
|
children: n.children,
|
||||||
handlers: n.handlers,
|
handlers: n.handlers,
|
||||||
priority: n.priority - 1,
|
priority: n.priority - 1,
|
||||||
|
fullPath: n.fullPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update maxParams (max of all children)
|
// 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 + "'")
|
panic("handlers are already registered for path '" + fullPath + "'")
|
||||||
}
|
}
|
||||||
n.handlers = handlers
|
n.handlers = handlers
|
||||||
|
n.fullPath = fullPath
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func checkRequests(t *testing.T, tree *node, requests testRequests, unescapes ..
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, request := range requests {
|
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 handler == nil {
|
||||||
if !request.nilHandler {
|
if !request.nilHandler {
|
||||||
@ -46,6 +46,9 @@ func checkRequests(t *testing.T, tree *node, requests testRequests, unescapes ..
|
|||||||
if fakeHandlerValue != request.route {
|
if fakeHandlerValue != request.route {
|
||||||
t.Errorf("handle mismatch for route '%s': Wrong handle (%s != %s)", request.path, 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) {
|
if !reflect.DeepEqual(ps, request.ps) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user