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 (
...
@@ -14,54 +14,81 @@ import (
)
)
var
(
var
(
// beego application
BeeApp
*
App
BeeApp
*
App
// application configurations
AppName
string
AppName
string
AppPath
string
AppPath
string
AppConfigPath
string
AppConfigPath
string
StaticDir
map
[
string
]
string
StaticDir
map
[
string
]
string
// template caching map
TemplateCache
map
[
string
]
*
template
.
Template
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
HttpAddr
string
HttpPort
int
HttpPort
int
HttpTLS
bool
HttpTLS
bool
HttpCertFile
string
HttpCertFile
string
HttpKeyFile
string
HttpKeyFile
string
// flag of auto recover panic
RecoverPanic
bool
RecoverPanic
bool
// flag of render template automatically
AutoRender
bool
AutoRender
bool
ViewsPath
string
ViewsPath
string
RunMode
string
//"dev" or "prod"
// run mode, "dev" or "prod"
RunMode
string
AppConfig
config
.
ConfigContainer
AppConfig
config
.
ConfigContainer
//related to session
// global session mananger
GlobalSessions
*
session
.
Manager
//GlobalSessions
GlobalSessions
*
session
.
Manager
SessionOn
bool
// whether auto start session,default is false
// flag of starting session auto. default is false.
SessionProvider
string
// default session provider memory mysql redis
SessionOn
bool
SessionName
string
// sessionName cookie's name
// default session provider, memory, mysql , redis ,etc.
SessionGCMaxLifetime
int64
// session's gc maxlifetime
SessionProvider
string
SessionSavePath
string
// session savepath if use mysql/redis/file this set to the connectinfo
// 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
SessionHashFunc
string
// session hash salt string.
SessionHashKey
string
SessionHashKey
string
// the life time of session id in cookie.
SessionCookieLifeTime
int
SessionCookieLifeTime
int
UseFcgi
bool
UseFcgi
bool
MaxMemory
int64
MaxMemory
int64
EnableGzip
bool
// enable gzip
// flag of enable gzip
DirectoryIndex
bool
//enable DirectoryIndex default is false
EnableGzip
bool
EnableHotUpdate
bool
//enable HotUpdate default is false
// flag of display directory index. default is false.
HttpServerTimeOut
int64
//set httpserver timeout
DirectoryIndex
bool
ErrorsShow
bool
//set weather show errors
// flag of hot update checking in app self. default is false.
XSRFKEY
string
//set XSRF
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
EnableXSRF
bool
// the expiry of xsrf value.
XSRFExpire
int
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
TemplateLeft
string
TemplateRight
string
TemplateRight
string
// beego server name exported in response header.
BeegoServerName
string
BeegoServerName
string
EnableAdmin
bool
//enable admin module to log api time
// flag of enable admin module to log every request info.
AdminHttpAddr
string
//admin module http addr
EnableAdmin
bool
// http server configurations for admin module.
AdminHttpAddr
string
AdminHttpPort
int
AdminHttpPort
int
)
)
func
init
()
{
func
init
()
{
// create bee
app
// create bee
go application
BeeApp
=
NewApp
()
BeeApp
=
NewApp
()
// initialize default configurations
// initialize default configurations
...
@@ -100,7 +127,7 @@ func init() {
...
@@ -100,7 +127,7 @@ func init() {
UseFcgi
=
false
UseFcgi
=
false
MaxMemory
=
1
<<
26
//64MB
MaxMemory
=
1
<<
26
//64MB
EnableGzip
=
false
EnableGzip
=
false
...
@@ -135,7 +162,8 @@ func init() {
...
@@ -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
)
{
func
ParseConfig
()
(
err
error
)
{
AppConfig
,
err
=
config
.
NewConfig
(
"ini"
,
AppConfigPath
)
AppConfig
,
err
=
config
.
NewConfig
(
"ini"
,
AppConfigPath
)
if
err
!=
nil
{
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 (
...
@@ -5,6 +5,8 @@ import (
"strings"
"strings"
)
)
// FilterRouter defines filter operation before controller handler execution.
// it can match patterned url and do filter function when action arrives.
type
FilterRouter
struct
{
type
FilterRouter
struct
{
pattern
string
pattern
string
regex
*
regexp
.
Regexp
regex
*
regexp
.
Regexp
...
@@ -14,6 +16,8 @@ type FilterRouter struct {
...
@@ -14,6 +16,8 @@ type FilterRouter struct {
parseParams
map
[
string
]
string
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
)
{
func
(
mr
*
FilterRouter
)
ValidRouter
(
router
string
)
(
bool
,
map
[
string
]
string
)
{
if
mr
.
pattern
==
""
{
if
mr
.
pattern
==
""
{
return
true
,
nil
return
true
,
nil
...
...
flash.go
View file @
b459cf23
...
@@ -6,18 +6,22 @@ import (
...
@@ -6,18 +6,22 @@ import (
"strings"
"strings"
)
)
// the separation string when encoding flash data.
const
BEEGO_FLASH_SEP
=
"#BEEGOFLASH#"
const
BEEGO_FLASH_SEP
=
"#BEEGOFLASH#"
// FlashData is a tools to maintain data when using across request.
type
FlashData
struct
{
type
FlashData
struct
{
Data
map
[
string
]
string
Data
map
[
string
]
string
}
}
// NewFlash return a new empty FlashData struct.
func
NewFlash
()
*
FlashData
{
func
NewFlash
()
*
FlashData
{
return
&
FlashData
{
return
&
FlashData
{
Data
:
make
(
map
[
string
]
string
),
Data
:
make
(
map
[
string
]
string
),
}
}
}
}
// Notice writes notice message to flash.
func
(
fd
*
FlashData
)
Notice
(
msg
string
,
args
...
interface
{})
{
func
(
fd
*
FlashData
)
Notice
(
msg
string
,
args
...
interface
{})
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
fd
.
Data
[
"notice"
]
=
msg
fd
.
Data
[
"notice"
]
=
msg
...
@@ -26,6 +30,7 @@ func (fd *FlashData) Notice(msg string, args ...interface{}) {
...
@@ -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
{})
{
func
(
fd
*
FlashData
)
Warning
(
msg
string
,
args
...
interface
{})
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
fd
.
Data
[
"warning"
]
=
msg
fd
.
Data
[
"warning"
]
=
msg
...
@@ -34,6 +39,7 @@ func (fd *FlashData) Warning(msg string, args ...interface{}) {
...
@@ -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
{})
{
func
(
fd
*
FlashData
)
Error
(
msg
string
,
args
...
interface
{})
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
fd
.
Data
[
"error"
]
=
msg
fd
.
Data
[
"error"
]
=
msg
...
@@ -42,6 +48,8 @@ func (fd *FlashData) Error(msg string, args ...interface{}) {
...
@@ -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
)
{
func
(
fd
*
FlashData
)
Store
(
c
*
Controller
)
{
c
.
Data
[
"flash"
]
=
fd
.
Data
c
.
Data
[
"flash"
]
=
fd
.
Data
var
flashValue
string
var
flashValue
string
...
@@ -51,6 +59,7 @@ func (fd *FlashData) Store(c *Controller) {
...
@@ -51,6 +59,7 @@ func (fd *FlashData) Store(c *Controller) {
c
.
Ctx
.
SetCookie
(
"BEEGO_FLASH"
,
url
.
QueryEscape
(
flashValue
),
0
,
"/"
)
c
.
Ctx
.
SetCookie
(
"BEEGO_FLASH"
,
url
.
QueryEscape
(
flashValue
),
0
,
"/"
)
}
}
// ReadFromRequest parsed flash data from encoded values in cookie.
func
ReadFromRequest
(
c
*
Controller
)
*
FlashData
{
func
ReadFromRequest
(
c
*
Controller
)
*
FlashData
{
flash
:=
&
FlashData
{
flash
:=
&
FlashData
{
Data
:
make
(
map
[
string
]
string
),
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