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
adbae18e
Commit
adbae18e
authored
Mar 09, 2016
by
saturn4er
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting with gofmt
parent
2c5ef8cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
controller.go
controller.go
+19
-19
staticfile_test.go
staticfile_test.go
+1
-1
No files found.
controller.go
View file @
adbae18e
...
...
@@ -34,14 +34,14 @@ import (
//commonly used mime-types
const
(
applicationJSON
=
"application/json"
applicationXML
=
"application/xml"
textXML
=
"text/xml"
applicationXML
=
"application/xml"
textXML
=
"text/xml"
)
var
(
// ErrAbort custom error when user stop request handler manually.
// ErrAbort custom error when user stop request handler manually.
ErrAbort
=
errors
.
New
(
"User stop run"
)
// GlobalControllerRouter store comments with controller. pkgpath+controller:comments
// GlobalControllerRouter store comments with controller. pkgpath+controller:comments
GlobalControllerRouter
=
make
(
map
[
string
][]
ControllerComments
)
)
...
...
@@ -56,31 +56,31 @@ type ControllerComments struct {
// Controller defines some basic http request handler operations, such as
// http context, template and view, session and xsrf.
type
Controller
struct
{
// context data
Ctx
*
context
.
Context
Data
map
[
interface
{}]
interface
{}
// context data
Ctx
*
context
.
Context
Data
map
[
interface
{}]
interface
{}
// route controller info
// route controller info
controllerName
string
actionName
string
methodMapping
map
[
string
]
func
()
//method:routertree
gotofunc
string
AppController
interface
{}
// template data
// template data
TplName
string
Layout
string
LayoutSections
map
[
string
]
string
// the key is the section name and the value is the template name
TplExt
string
EnableRender
bool
// xsrf data
_xsrfToken
string
XSRFExpire
int
EnableXSRF
bool
// xsrf data
_xsrfToken
string
XSRFExpire
int
EnableXSRF
bool
// session
CruSession
session
.
Store
// session
CruSession
session
.
Store
}
// ControllerInterface is an interface to uniform all controller handler.
...
...
@@ -284,7 +284,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string {
return
""
}
if
endpoint
[
0
]
==
'.'
{
return
URLFor
(
reflect
.
Indirect
(
reflect
.
ValueOf
(
c
.
AppController
))
.
Type
()
.
Name
()
+
endpoint
,
values
...
)
return
URLFor
(
reflect
.
Indirect
(
reflect
.
ValueOf
(
c
.
AppController
))
.
Type
()
.
Name
()
+
endpoint
,
values
...
)
}
return
URLFor
(
endpoint
,
values
...
)
}
...
...
@@ -292,7 +292,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string {
// ServeJSON sends a json response with encoding charset.
func
(
c
*
Controller
)
ServeJSON
(
encoding
...
bool
)
{
var
(
hasIndent
=
true
hasIndent
=
true
hasEncoding
=
false
)
if
BConfig
.
RunMode
==
PROD
{
...
...
@@ -490,7 +490,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error {
return
err
}
defer
file
.
Close
()
f
,
err
:=
os
.
OpenFile
(
tofile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0666
)
f
,
err
:=
os
.
OpenFile
(
tofile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0666
)
if
err
!=
nil
{
return
err
}
...
...
@@ -588,7 +588,7 @@ func (c *Controller) CheckXSRFCookie() bool {
// XSRFFormHTML writes an input field contains xsrf token value.
func
(
c
*
Controller
)
XSRFFormHTML
()
string
{
return
`<input type="hidden" name="_xsrf" value="`
+
c
.
XSRFToken
()
+
`" />`
c
.
XSRFToken
()
+
`" />`
}
// GetControllerAndAction gets the executing controller name and action name.
...
...
staticfile_test.go
View file @
adbae18e
...
...
@@ -7,8 +7,8 @@ import (
"io"
"io/ioutil"
"os"
"testing"
"path/filepath"
"testing"
)
var
currentWorkDir
,
_
=
os
.
Getwd
()
...
...
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