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
c3bc2bed
authored
2013-12-17 11:19:18 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add methodName to fix #380 & arrangement the router
1 parent
7b27b7fe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
controller.go
router.go
controller.go
View file @
c3bc2be
...
...
@@ -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 @
c3bc2be
This diff is collapsed.
Click to expand it.
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