Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
f6c7a6bd
Commit
f6c7a6bd
authored
May 27, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego: improve the admin router print
parent
d2eece9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
30 deletions
+42
-30
admin.go
admin.go
+20
-8
router.go
router.go
+22
-22
No files found.
admin.go
View file @
f6c7a6bd
...
...
@@ -122,17 +122,29 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
case
"router"
:
fmt
.
Fprintln
(
rw
,
"Print all router infomation:"
)
for
_
,
router
:=
range
BeeApp
.
Handlers
.
fixrouters
{
if
router
.
hasMethod
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
methods
,
"----"
,
router
.
controllerType
.
Name
())
}
else
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
controllerType
.
Name
())
if
router
.
routerType
==
routerTypeBeego
{
if
router
.
hasMethod
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
methods
,
"----"
,
router
.
controllerType
.
Name
())
}
else
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
controllerType
.
Name
())
}
}
else
if
router
.
routerType
==
routerTypeRESTFul
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
methods
,
"----"
,
router
.
runfunction
)
}
else
if
router
.
routerType
==
routerTypeHandler
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
handler
)
}
}
for
_
,
router
:=
range
BeeApp
.
Handlers
.
routers
{
if
router
.
hasMethod
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
methods
,
"----"
,
router
.
controllerType
.
Name
())
}
else
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
controllerType
.
Name
())
if
router
.
routerType
==
routerTypeBeego
{
if
router
.
hasMethod
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
methods
,
"----"
,
router
.
controllerType
.
Name
())
}
else
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
controllerType
.
Name
())
}
}
else
if
router
.
routerType
==
routerTypeRESTFul
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
methods
,
"----"
,
router
.
runfunction
)
}
else
if
router
.
routerType
==
routerTypeHandler
{
fmt
.
Fprintln
(
rw
,
router
.
pattern
,
"----"
,
router
.
handler
)
}
}
if
BeeApp
.
Handlers
.
enableAuto
{
...
...
router.go
View file @
f6c7a6bd
...
...
@@ -525,7 +525,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
}
controllName
:=
strings
.
Join
(
paths
[
:
len
(
paths
)
-
1
],
"."
)
methodName
:=
paths
[
len
(
paths
)
-
1
]
for
_
,
route
:=
range
p
.
fix
routers
{
for
_
,
route
:=
range
p
.
routers
{
if
route
.
controllerType
.
Name
()
==
controllName
{
var
finded
bool
if
utils
.
InSlice
(
strings
.
ToLower
(
methodName
),
HTTPMETHOD
)
{
...
...
@@ -550,13 +550,27 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
if
!
finded
{
continue
}
if
len
(
values
)
>
0
{
return
route
.
pattern
+
"?"
+
urlv
.
Encode
()
var
returnurl
string
var
i
int
var
startreg
bool
for
_
,
v
:=
range
route
.
regex
.
String
()
{
if
v
==
'('
{
startreg
=
true
continue
}
else
if
v
==
')'
{
startreg
=
false
returnurl
=
returnurl
+
urlv
.
Get
(
route
.
params
[
i
])
i
++
}
else
if
!
startreg
{
returnurl
=
string
(
append
([]
rune
(
returnurl
),
v
))
}
}
if
route
.
regex
.
MatchString
(
returnurl
)
{
return
returnurl
}
return
route
.
pattern
}
}
for
_
,
route
:=
range
p
.
routers
{
for
_
,
route
:=
range
p
.
fix
routers
{
if
route
.
controllerType
.
Name
()
==
controllName
{
var
finded
bool
if
utils
.
InSlice
(
strings
.
ToLower
(
methodName
),
HTTPMETHOD
)
{
...
...
@@ -581,24 +595,10 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
if
!
finded
{
continue
}
var
returnurl
string
var
i
int
var
startreg
bool
for
_
,
v
:=
range
route
.
regex
.
String
()
{
if
v
==
'('
{
startreg
=
true
continue
}
else
if
v
==
')'
{
startreg
=
false
returnurl
=
returnurl
+
urlv
.
Get
(
route
.
params
[
i
])
i
++
}
else
if
!
startreg
{
returnurl
=
string
(
append
([]
rune
(
returnurl
),
v
))
}
}
if
route
.
regex
.
MatchString
(
returnurl
)
{
return
returnurl
if
len
(
values
)
>
0
{
return
route
.
pattern
+
"?"
+
urlv
.
Encode
()
}
return
route
.
pattern
}
}
if
p
.
enableAuto
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment