1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-18 00:10:55 +00:00

for the root path, all methods must be covered

use continue instead of return
This commit is contained in:
Silviu Capota-Mera 2017-10-07 13:16:36 -04:00 committed by GitHub
parent fd733f76f0
commit 8d59e7afd1

20
app.go
View File

@ -226,7 +226,7 @@ func UnregisterFixedRoute(fixedRoute string, method string) *App {
} }
if BeeApp.Handlers.routers[m].prefix == strings.Trim(fixedRoute, "/ ") { if BeeApp.Handlers.routers[m].prefix == strings.Trim(fixedRoute, "/ ") {
findAndRemoveSingleTree(BeeApp.Handlers.routers[m]) findAndRemoveSingleTree(BeeApp.Handlers.routers[m])
return BeeApp continue
} }
findAndRemoveTree(subPaths, BeeApp.Handlers.routers[m], m) findAndRemoveTree(subPaths, BeeApp.Handlers.routers[m], m)
} }
@ -273,16 +273,16 @@ func findAndRemoveTree(paths []string, entryPointTree *Tree, method string) {
} }
func findAndRemoveSingleTree(entryPointTree *Tree) { func findAndRemoveSingleTree(entryPointTree *Tree) {
if entryPointTree == nil {
if len(entryPointTree.fixrouters) > 0 { return
// Remove the *Tree from the fixrouters slice
entryPointTree.fixrouters[0] = nil
entryPointTree.fixrouters = entryPointTree.fixrouters[1:]
} }
if len(entryPointTree.fixrouters) > 0 {
if len(entryPointTree.leaves) > 0 { // If the route had children subtrees, remove just the functional leaf,
entryPointTree.leaves[0] = nil // to allow children to function as before
entryPointTree.leaves = entryPointTree.leaves[1:] if len(entryPointTree.leaves) > 0 {
entryPointTree.leaves[0] = nil
entryPointTree.leaves = entryPointTree.leaves[1:]
}
} }
} }