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
cb49be78
Commit
cb49be78
authored
Dec 19, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix router Put and Delete method when post method with _method
parent
68d4c2c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
router.go
router.go
+15
-3
No files found.
router.go
View file @
cb49be78
...
...
@@ -575,7 +575,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if
requestPath
==
route
.
pattern
{
runrouter
=
route
.
controllerType
findrouter
=
true
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
route
)
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
context
.
Input
.
Query
(
"_method"
),
route
)
break
}
// pattern /admin url /admin 200 /admin/ 404
...
...
@@ -618,7 +618,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
runrouter
=
route
.
controllerType
findrouter
=
true
context
.
Input
.
Params
=
params
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
route
)
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
context
.
Input
.
Query
(
"_method"
),
route
)
break
}
}
...
...
@@ -788,7 +788,7 @@ func (p *ControllerRegistor) getErrorHandler(errorCode string) func(rw http.Resp
return
handler
}
func
(
p
*
ControllerRegistor
)
getRunMethod
(
method
string
,
router
*
controllerInfo
)
string
{
func
(
p
*
ControllerRegistor
)
getRunMethod
(
method
,
_method
string
,
router
*
controllerInfo
)
string
{
method
=
strings
.
ToLower
(
method
)
if
router
.
hasMethod
{
if
m
,
ok
:=
router
.
methods
[
method
];
ok
{
...
...
@@ -796,9 +796,21 @@ func (p *ControllerRegistor) getRunMethod(method string, router *controllerInfo)
}
else
if
m
,
ok
=
router
.
methods
[
"*"
];
ok
{
return
m
}
else
{
if
method
==
"POST"
||
strings
.
ToLower
(
_method
)
==
"put"
{
return
"Put"
}
if
method
==
"POST"
||
strings
.
ToLower
(
_method
)
==
"delete"
{
return
"Delete"
}
return
strings
.
Title
(
method
)
}
}
else
{
if
method
==
"POST"
||
strings
.
ToLower
(
_method
)
==
"put"
{
return
"Put"
}
if
method
==
"POST"
||
strings
.
ToLower
(
_method
)
==
"delete"
{
return
"Delete"
}
return
strings
.
Title
(
method
)
}
}
...
...
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