1
0
镜像自地址 https://github.com/astaxie/beego.git 已同步 2025-07-17 18:52:16 +00:00

Update beego.go - Modify GroupRouters all function

Modify the file beego.go. 
Type GroupRouters all function 
Slice types exist trap bug.
这个提交包含在:
cnphpbb
2014-03-12 16:50:13 +08:00
父节点 5583fa2054
当前提交 0f015d75d2

查看文件

@@ -28,12 +28,12 @@ type GroupRouters []groupRouter
// Get a new GroupRouters // Get a new GroupRouters
func NewGroupRouters() GroupRouters { func NewGroupRouters() GroupRouters {
return make([]groupRouter, 0) return make(GroupRouters, 0)
} }
// Add Router in the GroupRouters // Add Router in the GroupRouters
// it is for plugin or module to register router // it is for plugin or module to register router
func (gr GroupRouters) AddRouter(pattern string, c ControllerInterface, mappingMethod ...string) { func (gr *GroupRouters) AddRouter(pattern string, c ControllerInterface, mappingMethod ...string) {
var newRG groupRouter var newRG groupRouter
if len(mappingMethod) > 0 { if len(mappingMethod) > 0 {
newRG = groupRouter{ newRG = groupRouter{
@@ -48,16 +48,16 @@ func (gr GroupRouters) AddRouter(pattern string, c ControllerInterface, mappingM
"", "",
} }
} }
gr = append(gr, newRG) *gr = append(*gr, newRG)
} }
func (gr GroupRouters) AddAuto(c ControllerInterface) { func (gr *GroupRouters) AddAuto(c ControllerInterface) {
newRG := groupRouter{ newRG := groupRouter{
"", "",
c, c,
"", "",
} }
gr = append(gr, newRG) *gr = append(*gr, newRG)
} }
// AddGroupRouter with the prefix // AddGroupRouter with the prefix