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
b459cf23
Commit
b459cf23
authored
Dec 20, 2013
by
傅小黑
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add api comments in file config.go, controller.go, filter.go and flash.go
parent
933e98e4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
21 deletions
+62
-21
config.go
config.go
+49
-21
controller.go
controller.go
+0
-0
filter.go
filter.go
+4
-0
flash.go
flash.go
+9
-0
No files found.
config.go
View file @
b459cf23
...
...
@@ -14,54 +14,81 @@ import (
)
var
(
// beego application
BeeApp
*
App
// application configurations
AppName
string
AppPath
string
AppConfigPath
string
StaticDir
map
[
string
]
string
// template caching map
TemplateCache
map
[
string
]
*
template
.
Template
StaticExtensionsToGzip
[]
string
//Files which should also be compressed with gzip (.js, .css, etc)
// files with should be compressed with gzip (.js,.css,etc)
StaticExtensionsToGzip
[]
string
// http server configurations
HttpAddr
string
HttpPort
int
HttpTLS
bool
HttpCertFile
string
HttpKeyFile
string
// flag of auto recover panic
RecoverPanic
bool
// flag of render template automatically
AutoRender
bool
ViewsPath
string
RunMode
string
//"dev" or "prod"
// run mode, "dev" or "prod"
RunMode
string
AppConfig
config
.
ConfigContainer
//related to session
GlobalSessions
*
session
.
Manager
//GlobalSessions
SessionOn
bool
// whether auto start session,default is false
SessionProvider
string
// default session provider memory mysql redis
SessionName
string
// sessionName cookie's name
SessionGCMaxLifetime
int64
// session's gc maxlifetime
SessionSavePath
string
// session savepath if use mysql/redis/file this set to the connectinfo
// global session mananger
GlobalSessions
*
session
.
Manager
// flag of starting session auto. default is false.
SessionOn
bool
// default session provider, memory, mysql , redis ,etc.
SessionProvider
string
// the cookie name when saving session id into cookie.
SessionName
string
// session gc time for auto cleaning expired session.
SessionGCMaxLifetime
int64
// if use mysql/redis/file provider, define save path to connection info.
SessionSavePath
string
// session hash generation func.
SessionHashFunc
string
// session hash salt string.
SessionHashKey
string
// the life time of session id in cookie.
SessionCookieLifeTime
int
UseFcgi
bool
MaxMemory
int64
EnableGzip
bool
// enable gzip
DirectoryIndex
bool
//enable DirectoryIndex default is false
EnableHotUpdate
bool
//enable HotUpdate default is false
HttpServerTimeOut
int64
//set httpserver timeout
ErrorsShow
bool
//set weather show errors
XSRFKEY
string
//set XSRF
// flag of enable gzip
EnableGzip
bool
// flag of display directory index. default is false.
DirectoryIndex
bool
// flag of hot update checking in app self. default is false.
EnableHotUpdate
bool
HttpServerTimeOut
int64
// flag of show errors in page. if true, show error and trace info in page rendered with error template.
ErrorsShow
bool
// xsrf hash salt string.
XSRFKEY
string
// flag of enable xsrf.
EnableXSRF
bool
// the expiry of xsrf value.
XSRFExpire
int
CopyRequestBody
bool
//When in raw application, You want to the reqeustbody
// flag of copy raw request body in context.
CopyRequestBody
bool
TemplateLeft
string
TemplateRight
string
// beego server name exported in response header.
BeegoServerName
string
EnableAdmin
bool
//enable admin module to log api time
AdminHttpAddr
string
//admin module http addr
// flag of enable admin module to log every request info.
EnableAdmin
bool
// http server configurations for admin module.
AdminHttpAddr
string
AdminHttpPort
int
)
func
init
()
{
// create bee
app
// create bee
go application
BeeApp
=
NewApp
()
// initialize default configurations
...
...
@@ -100,7 +127,7 @@ func init() {
UseFcgi
=
false
MaxMemory
=
1
<<
26
//64MB
MaxMemory
=
1
<<
26
//64MB
EnableGzip
=
false
...
...
@@ -135,7 +162,8 @@ func init() {
}
}
//parse config now only support ini, next will support json
// ParseConfig parsed default config file.
// now only support ini, next will support json.
func
ParseConfig
()
(
err
error
)
{
AppConfig
,
err
=
config
.
NewConfig
(
"ini"
,
AppConfigPath
)
if
err
!=
nil
{
...
...
controller.go
View file @
b459cf23
This diff is collapsed.
Click to expand it.
filter.go
View file @
b459cf23
...
...
@@ -5,6 +5,8 @@ import (
"strings"
)
// FilterRouter defines filter operation before controller handler execution.
// it can match patterned url and do filter function when action arrives.
type
FilterRouter
struct
{
pattern
string
regex
*
regexp
.
Regexp
...
...
@@ -14,6 +16,8 @@ type FilterRouter struct {
parseParams
map
[
string
]
string
}
// ValidRouter check current request is valid for this filter.
// if matched, returns parsed params in this request by defined filter router pattern.
func
(
mr
*
FilterRouter
)
ValidRouter
(
router
string
)
(
bool
,
map
[
string
]
string
)
{
if
mr
.
pattern
==
""
{
return
true
,
nil
...
...
flash.go
View file @
b459cf23
...
...
@@ -6,18 +6,22 @@ import (
"strings"
)
// the separation string when encoding flash data.
const
BEEGO_FLASH_SEP
=
"#BEEGOFLASH#"
// FlashData is a tools to maintain data when using across request.
type
FlashData
struct
{
Data
map
[
string
]
string
}
// NewFlash return a new empty FlashData struct.
func
NewFlash
()
*
FlashData
{
return
&
FlashData
{
Data
:
make
(
map
[
string
]
string
),
}
}
// Notice writes notice message to flash.
func
(
fd
*
FlashData
)
Notice
(
msg
string
,
args
...
interface
{})
{
if
len
(
args
)
==
0
{
fd
.
Data
[
"notice"
]
=
msg
...
...
@@ -26,6 +30,7 @@ func (fd *FlashData) Notice(msg string, args ...interface{}) {
}
}
// Warning writes warning message to flash.
func
(
fd
*
FlashData
)
Warning
(
msg
string
,
args
...
interface
{})
{
if
len
(
args
)
==
0
{
fd
.
Data
[
"warning"
]
=
msg
...
...
@@ -34,6 +39,7 @@ func (fd *FlashData) Warning(msg string, args ...interface{}) {
}
}
// Error writes error message to flash.
func
(
fd
*
FlashData
)
Error
(
msg
string
,
args
...
interface
{})
{
if
len
(
args
)
==
0
{
fd
.
Data
[
"error"
]
=
msg
...
...
@@ -42,6 +48,8 @@ func (fd *FlashData) Error(msg string, args ...interface{}) {
}
}
// Store does the saving operation of flash data.
// the data are encoded and saved in cookie.
func
(
fd
*
FlashData
)
Store
(
c
*
Controller
)
{
c
.
Data
[
"flash"
]
=
fd
.
Data
var
flashValue
string
...
...
@@ -51,6 +59,7 @@ func (fd *FlashData) Store(c *Controller) {
c
.
Ctx
.
SetCookie
(
"BEEGO_FLASH"
,
url
.
QueryEscape
(
flashValue
),
0
,
"/"
)
}
// ReadFromRequest parsed flash data from encoded values in cookie.
func
ReadFromRequest
(
c
*
Controller
)
*
FlashData
{
flash
:=
&
FlashData
{
Data
:
make
(
map
[
string
]
string
),
...
...
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