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
053e7a6a
authored
2013-12-24 21:09:17 +0800
by
傅小黑
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'astaxie/master'
2 parents
ba94479e
62188a37
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
controller.go
router.go
controller.go
View file @
053e7a6
...
...
@@ -38,6 +38,7 @@ type Controller struct {
actionName
string
TplNames
string
Layout
string
LayoutSections
map
[
string
]
string
// the key is the section name and the value is the template name
TplExt
string
_xsrf_token
string
gotofunc
string
...
...
@@ -161,6 +162,25 @@ func (c *Controller) RenderBytes() ([]byte, error) {
}
tplcontent
,
_
:=
ioutil
.
ReadAll
(
newbytes
)
c
.
Data
[
"LayoutContent"
]
=
template
.
HTML
(
string
(
tplcontent
))
if
c
.
LayoutSections
!=
nil
{
for
sectionName
,
sectionTpl
:=
range
c
.
LayoutSections
{
if
(
sectionTpl
==
""
)
{
c
.
Data
[
sectionName
]
=
""
continue
}
sectionBytes
:=
bytes
.
NewBufferString
(
""
)
err
=
BeeTemplates
[
sectionTpl
]
.
ExecuteTemplate
(
sectionBytes
,
sectionTpl
,
c
.
Data
)
if
err
!=
nil
{
Trace
(
"template Execute err:"
,
err
)
return
nil
,
err
}
sectionContent
,
_
:=
ioutil
.
ReadAll
(
sectionBytes
)
c
.
Data
[
sectionName
]
=
template
.
HTML
(
string
(
sectionContent
))
}
}
ibytes
:=
bytes
.
NewBufferString
(
""
)
err
=
BeeTemplates
[
c
.
Layout
]
.
ExecuteTemplate
(
ibytes
,
c
.
Layout
,
c
.
Data
)
if
err
!=
nil
{
...
...
router.go
View file @
053e7a6
...
...
@@ -566,11 +566,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
for
_
,
route
:=
range
p
.
fixrouters
{
n
:=
len
(
requestPath
)
if
requestPath
==
route
.
pattern
{
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
context
,
route
)
if
runMethod
!=
""
{
runrouter
=
route
.
controllerType
findrouter
=
true
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
context
,
route
)
break
}
}
// pattern /admin url /admin 200 /admin/ 404
// pattern /admin/ url /admin 301 /admin/ 200
if
requestPath
[
n
-
1
]
!=
'/'
&&
len
(
route
.
pattern
)
==
n
+
1
&&
...
...
@@ -608,13 +610,15 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
//reassemble query params and add to RawQuery
r
.
URL
.
RawQuery
=
url
.
Values
(
values
)
.
Encode
()
}
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
context
,
route
)
if
runMethod
!=
""
{
runrouter
=
route
.
controllerType
findrouter
=
true
context
.
Input
.
Params
=
params
runMethod
=
p
.
getRunMethod
(
r
.
Method
,
context
,
route
)
findrouter
=
true
break
}
}
}
if
!
findrouter
&&
p
.
enableAuto
{
// deal with url with diffirent ext
...
...
@@ -798,7 +802,7 @@ func (p *ControllerRegistor) getRunMethod(method string, context *beecontext.Con
}
else
if
m
,
ok
=
router
.
methods
[
"*"
];
ok
{
return
m
}
else
{
return
strings
.
Title
(
method
)
return
""
}
}
else
{
return
strings
.
Title
(
method
)
...
...
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