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
868e14b8
Commit
868e14b8
authored
Sep 15, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #2017
parent
421bf97b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
input.go
context/input.go
+8
-6
router.go
router.go
+13
-4
No files found.
context/input.go
View file @
868e14b8
...
...
@@ -40,12 +40,14 @@ var (
// BeegoInput operates the http request header, data, cookie and body.
// it also contains router params and current session.
type
BeegoInput
struct
{
Context
*
Context
CruSession
session
.
Store
pnames
[]
string
pvalues
[]
string
data
map
[
interface
{}]
interface
{}
// store some values in this context when calling context in filter or controller.
RequestBody
[]
byte
Context
*
Context
CruSession
session
.
Store
pnames
[]
string
pvalues
[]
string
data
map
[
interface
{}]
interface
{}
// store some values in this context when calling context in filter or controller.
RequestBody
[]
byte
RunMethod
string
RunController
reflect
.
Type
}
// NewInput return BeegoInput generated by Context.
...
...
router.go
View file @
868e14b8
...
...
@@ -685,8 +685,16 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if
len
(
p
.
filters
[
BeforeRouter
])
>
0
&&
p
.
execFilter
(
context
,
urlPath
,
BeforeRouter
)
{
goto
Admin
}
// User can define RunController and RunMethod in filter
if
context
.
Input
.
RunController
!=
nil
&&
context
.
Input
.
RunMethod
!=
""
{
findRouter
=
true
isRunnable
=
true
runMethod
=
context
.
Input
.
RunMethod
runRouter
=
context
.
Input
.
RunController
}
else
{
routerInfo
,
findRouter
=
p
.
FindRouter
(
context
)
}
routerInfo
,
findRouter
=
p
.
FindRouter
(
context
)
//if no matches to url, throw a not found exception
if
!
findRouter
{
exception
(
"404"
,
context
)
...
...
@@ -698,15 +706,16 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
}
}
//store router pattern into context
context
.
Input
.
SetData
(
"RouterPattern"
,
routerInfo
.
pattern
)
//execute middleware filters
if
len
(
p
.
filters
[
BeforeExec
])
>
0
&&
p
.
execFilter
(
context
,
urlPath
,
BeforeExec
)
{
goto
Admin
}
if
routerInfo
!=
nil
{
if
BConfig
.
RunMode
==
DEV
{
//store router pattern into context
context
.
Input
.
SetData
(
"RouterPattern"
,
routerInfo
.
pattern
)
}
if
routerInfo
.
routerType
==
routerTypeRESTFul
{
if
_
,
ok
:=
routerInfo
.
methods
[
r
.
Method
];
ok
{
isRunnable
=
true
...
...
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