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
c13141b8
Commit
c13141b8
authored
Jun 11, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego:fix when user defined function equal to HTTP
parent
aa275fb5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
router.go
router.go
+7
-6
router_test.go
router_test.go
+7
-3
No files found.
router.go
View file @
c13141b8
...
...
@@ -428,14 +428,13 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin
if
c
.
routerType
==
routerTypeBeego
&&
c
.
controllerType
.
Name
()
==
controllName
{
find
:=
false
if
_
,
ok
:=
HTTPMETHOD
[
strings
.
ToUpper
(
methodName
)];
ok
{
if
m
,
ok
:=
c
.
methods
[
strings
.
ToUpper
(
methodName
)];
ok
&&
m
!=
strings
.
ToUpper
(
methodName
)
{
return
false
,
""
}
else
if
m
,
ok
=
c
.
methods
[
"*"
];
ok
&&
m
!=
methodName
{
return
false
,
""
}
else
{
if
m
,
ok
:=
c
.
methods
[
strings
.
ToUpper
(
methodName
)];
ok
&&
m
==
strings
.
ToUpper
(
methodName
)
{
find
=
true
}
else
if
m
,
ok
=
c
.
methods
[
"*"
];
ok
&&
m
==
methodName
{
find
=
true
}
}
else
{
}
if
!
find
{
for
_
,
md
:=
range
c
.
methods
{
if
md
==
methodName
{
find
=
true
...
...
@@ -507,6 +506,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin
return
true
,
url
}
}
}
else
{
return
false
,
""
}
}
}
...
...
router_test.go
View file @
c13141b8
...
...
@@ -27,6 +27,10 @@ func (this *TestController) Post() {
this
.
Ctx
.
Output
.
Body
([]
byte
(
this
.
Ctx
.
Input
.
Query
(
":name"
)))
}
func
(
this
*
TestController
)
Param
()
{
this
.
Ctx
.
Output
.
Body
([]
byte
(
this
.
Ctx
.
Input
.
Query
(
":name"
)))
}
func
(
this
*
TestController
)
List
()
{
this
.
Ctx
.
Output
.
Body
([]
byte
(
"i am list"
))
}
...
...
@@ -74,14 +78,14 @@ func (this *JsonController) Get() {
func
TestUrlFor
(
t
*
testing
.
T
)
{
handler
:=
NewControllerRegister
()
handler
.
Add
(
"/api/list"
,
&
TestController
{},
"*:List"
)
handler
.
Add
(
"/person/:last/:first"
,
&
TestController
{})
handler
.
Add
(
"/person/:last/:first"
,
&
TestController
{}
,
"*:Param"
)
handler
.
AddAuto
(
&
TestController
{})
if
handler
.
UrlFor
(
"TestController.List"
)
!=
"/api/list"
{
Info
(
handler
.
UrlFor
(
"TestController.List"
))
t
.
Errorf
(
"TestController.List must equal to /api/list"
)
}
if
handler
.
UrlFor
(
"TestController.
Get
"
,
":last"
,
"xie"
,
":first"
,
"asta"
)
!=
"/person/xie/asta"
{
t
.
Errorf
(
"TestController.
Get must equal to /person/xie/asta"
)
if
handler
.
UrlFor
(
"TestController.
Param
"
,
":last"
,
"xie"
,
":first"
,
"asta"
)
!=
"/person/xie/asta"
{
t
.
Errorf
(
"TestController.
Param must equal to /person/xie/asta, but get "
+
handler
.
UrlFor
(
"TestController.Param"
,
":last"
,
"xie"
,
":first"
,
"asta"
)
)
}
if
handler
.
UrlFor
(
"TestController.Myext"
)
!=
"/test/myext"
{
t
.
Errorf
(
"TestController.Myext must equal to /test/myext"
)
...
...
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