1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-18 00:30:54 +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

14
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,17 +273,17 @@ 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 the route had children subtrees, remove just the functional leaf,
// to allow children to function as before
if len(entryPointTree.leaves) > 0 { if len(entryPointTree.leaves) > 0 {
entryPointTree.leaves[0] = nil entryPointTree.leaves[0] = nil
entryPointTree.leaves = entryPointTree.leaves[1:] entryPointTree.leaves = entryPointTree.leaves[1:]
} }
}
} }
// Include will generate router file in the router/xxx.go from the controller's comments // Include will generate router file in the router/xxx.go from the controller's comments