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
c3bc2bed
Commit
c3bc2bed
authored
Dec 17, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add methodName to fix #380 & arrangement the router
parent
7b27b7fe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
controller.go
controller.go
+18
-16
router.go
router.go
+0
-0
No files found.
controller.go
View file @
c3bc2bed
...
...
@@ -29,21 +29,22 @@ var (
)
type
Controller
struct
{
Ctx
*
context
.
Context
Data
map
[
interface
{}]
interface
{}
ChildName
string
TplNames
string
Layout
string
TplExt
string
_xsrf_token
string
gotofunc
string
CruSession
session
.
SessionStore
XSRFExpire
int
AppController
interface
{}
Ctx
*
context
.
Context
Data
map
[
interface
{}]
interface
{}
controllerName
string
actionName
string
TplNames
string
Layout
string
TplExt
string
_xsrf_token
string
gotofunc
string
CruSession
session
.
SessionStore
XSRFExpire
int
AppController
interface
{}
}
type
ControllerInterface
interface
{
Init
(
ct
*
context
.
Context
,
c
hild
Name
string
,
app
interface
{})
Init
(
ct
*
context
.
Context
,
c
ontrollerName
,
action
Name
string
,
app
interface
{})
Prepare
()
Get
()
Post
()
...
...
@@ -56,11 +57,12 @@ type ControllerInterface interface {
Render
()
error
}
func
(
c
*
Controller
)
Init
(
ctx
*
context
.
Context
,
c
hild
Name
string
,
app
interface
{})
{
func
(
c
*
Controller
)
Init
(
ctx
*
context
.
Context
,
c
ontrollerName
,
action
Name
string
,
app
interface
{})
{
c
.
Data
=
make
(
map
[
interface
{}]
interface
{})
c
.
Layout
=
""
c
.
TplNames
=
""
c
.
ChildName
=
childName
c
.
controllerName
=
controllerName
c
.
actionName
=
actionName
c
.
Ctx
=
ctx
c
.
TplExt
=
"tpl"
c
.
AppController
=
app
...
...
@@ -123,7 +125,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
//if the controller has set layout, then first get the tplname's content set the content to the layout
if
c
.
Layout
!=
""
{
if
c
.
TplNames
==
""
{
c
.
TplNames
=
c
.
ChildName
+
"/"
+
strings
.
ToLower
(
c
.
Ctx
.
Request
.
Method
)
+
"."
+
c
.
TplExt
c
.
TplNames
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
}
if
RunMode
==
"dev"
{
BuildTemplate
(
ViewsPath
)
...
...
@@ -150,7 +152,7 @@ func (c *Controller) RenderBytes() ([]byte, error) {
return
icontent
,
nil
}
else
{
if
c
.
TplNames
==
""
{
c
.
TplNames
=
c
.
ChildName
+
"/"
+
strings
.
ToLower
(
c
.
Ctx
.
Request
.
Method
)
+
"."
+
c
.
TplExt
c
.
TplNames
=
strings
.
ToLower
(
c
.
controllerName
)
+
"/"
+
strings
.
ToLower
(
c
.
actionName
)
+
"."
+
c
.
TplExt
}
if
RunMode
==
"dev"
{
BuildTemplate
(
ViewsPath
)
...
...
router.go
View file @
c3bc2bed
This diff is collapsed.
Click to expand it.
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