Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2a4e2d4a
authored
2015-02-27 22:37:07 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
delete the group route, because we already has namespace
1 parent
f96a6285
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
67 deletions
beego.go
beego.go
View file @
2a4e2d4
...
...
@@ -42,73 +42,6 @@ const VERSION = "1.4.2"
type
hookfunc
func
()
error
//hook function to run
var
hooks
[]
hookfunc
//hook function slice to store the hookfunc
type
groupRouter
struct
{
pattern
string
controller
ControllerInterface
mappingMethods
string
}
// RouterGroups which will store routers
type
GroupRouters
[]
groupRouter
// Get a new GroupRouters
func
NewGroupRouters
()
GroupRouters
{
return
make
(
GroupRouters
,
0
)
}
// Add Router in the GroupRouters
// it is for plugin or module to register router
func
(
gr
*
GroupRouters
)
AddRouter
(
pattern
string
,
c
ControllerInterface
,
mappingMethod
...
string
)
{
var
newRG
groupRouter
if
len
(
mappingMethod
)
>
0
{
newRG
=
groupRouter
{
pattern
,
c
,
mappingMethod
[
0
],
}
}
else
{
newRG
=
groupRouter
{
pattern
,
c
,
""
,
}
}
*
gr
=
append
(
*
gr
,
newRG
)
}
func
(
gr
*
GroupRouters
)
AddAuto
(
c
ControllerInterface
)
{
newRG
:=
groupRouter
{
""
,
c
,
""
,
}
*
gr
=
append
(
*
gr
,
newRG
)
}
// AddGroupRouter with the prefix
// it will register the router in BeeApp
// the follow code is write in modules:
// GR:=NewGroupRouters()
// GR.AddRouter("/login",&UserController,"get:Login")
// GR.AddRouter("/logout",&UserController,"get:Logout")
// GR.AddRouter("/register",&UserController,"get:Reg")
// the follow code is write in app:
// import "github.com/beego/modules/auth"
// AddRouterGroup("/admin", auth.GR)
func
AddGroupRouter
(
prefix
string
,
groups
GroupRouters
)
*
App
{
for
_
,
v
:=
range
groups
{
if
v
.
pattern
==
""
{
BeeApp
.
Handlers
.
AddAutoPrefix
(
prefix
,
v
.
controller
)
}
else
if
v
.
mappingMethods
!=
""
{
BeeApp
.
Handlers
.
Add
(
prefix
+
v
.
pattern
,
v
.
controller
,
v
.
mappingMethods
)
}
else
{
BeeApp
.
Handlers
.
Add
(
prefix
+
v
.
pattern
,
v
.
controller
)
}
}
return
BeeApp
}
// Router adds a patterned controller handler to BeeApp.
// it's an alias method of App.Router.
// usage:
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment