2a4e2d4a by astaxie

delete the group route, because we already has namespace

1 parent f96a6285
Showing 1 changed file with 0 additions and 67 deletions
...@@ -42,73 +42,6 @@ const VERSION = "1.4.2" ...@@ -42,73 +42,6 @@ const VERSION = "1.4.2"
42 type hookfunc func() error //hook function to run 42 type hookfunc func() error //hook function to run
43 var hooks []hookfunc //hook function slice to store the hookfunc 43 var hooks []hookfunc //hook function slice to store the hookfunc
44 44
45 type groupRouter struct {
46 pattern string
47 controller ControllerInterface
48 mappingMethods string
49 }
50
51 // RouterGroups which will store routers
52 type GroupRouters []groupRouter
53
54 // Get a new GroupRouters
55 func NewGroupRouters() GroupRouters {
56 return make(GroupRouters, 0)
57 }
58
59 // Add Router in the GroupRouters
60 // it is for plugin or module to register router
61 func (gr *GroupRouters) AddRouter(pattern string, c ControllerInterface, mappingMethod ...string) {
62 var newRG groupRouter
63 if len(mappingMethod) > 0 {
64 newRG = groupRouter{
65 pattern,
66 c,
67 mappingMethod[0],
68 }
69 } else {
70 newRG = groupRouter{
71 pattern,
72 c,
73 "",
74 }
75 }
76 *gr = append(*gr, newRG)
77 }
78
79 func (gr *GroupRouters) AddAuto(c ControllerInterface) {
80 newRG := groupRouter{
81 "",
82 c,
83 "",
84 }
85 *gr = append(*gr, newRG)
86 }
87
88 // AddGroupRouter with the prefix
89 // it will register the router in BeeApp
90 // the follow code is write in modules:
91 // GR:=NewGroupRouters()
92 // GR.AddRouter("/login",&UserController,"get:Login")
93 // GR.AddRouter("/logout",&UserController,"get:Logout")
94 // GR.AddRouter("/register",&UserController,"get:Reg")
95 // the follow code is write in app:
96 // import "github.com/beego/modules/auth"
97 // AddRouterGroup("/admin", auth.GR)
98 func AddGroupRouter(prefix string, groups GroupRouters) *App {
99 for _, v := range groups {
100 if v.pattern == "" {
101 BeeApp.Handlers.AddAutoPrefix(prefix, v.controller)
102 } else if v.mappingMethods != "" {
103 BeeApp.Handlers.Add(prefix+v.pattern, v.controller, v.mappingMethods)
104 } else {
105 BeeApp.Handlers.Add(prefix+v.pattern, v.controller)
106 }
107
108 }
109 return BeeApp
110 }
111
112 // Router adds a patterned controller handler to BeeApp. 45 // Router adds a patterned controller handler to BeeApp.
113 // it's an alias method of App.Router. 46 // it's an alias method of App.Router.
114 // usage: 47 // usage:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!