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
f28a941e
Commit
f28a941e
authored
Sep 07, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make golint happy and also make the config readable
parent
152127c2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
42 deletions
+42
-42
admin.go
admin.go
+14
-14
app.go
app.go
+22
-22
beego.go
beego.go
+2
-2
config.go
config.go
+0
-0
hooks.go
hooks.go
+2
-2
router.go
router.go
+2
-2
No files found.
admin.go
View file @
f28a941e
...
...
@@ -101,11 +101,11 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
m
[
"AppConfigPath"
]
=
AppConfigPath
m
[
"StaticDir"
]
=
StaticDir
m
[
"StaticExtensionsToGzip"
]
=
StaticExtensionsToGzip
m
[
"H
ttpAddr"
]
=
Http
Addr
m
[
"H
ttpPort"
]
=
Http
Port
m
[
"H
ttpTLS"
]
=
EnableHttp
TLS
m
[
"H
ttpCertFile"
]
=
Http
CertFile
m
[
"H
ttpKeyFile"
]
=
Http
KeyFile
m
[
"H
TTPAddr"
]
=
HTTP
Addr
m
[
"H
TTPPort"
]
=
HTTP
Port
m
[
"H
TTPTLS"
]
=
EnableHTTP
TLS
m
[
"H
TTPCertFile"
]
=
HTTP
CertFile
m
[
"H
TTPKeyFile"
]
=
HTTP
KeyFile
m
[
"RecoverPanic"
]
=
RecoverPanic
m
[
"AutoRender"
]
=
AutoRender
m
[
"ViewsPath"
]
=
ViewsPath
...
...
@@ -114,14 +114,14 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
m
[
"SessionProvider"
]
=
SessionProvider
m
[
"SessionName"
]
=
SessionName
m
[
"SessionGCMaxLifetime"
]
=
SessionGCMaxLifetime
m
[
"Session
SavePath"
]
=
SessionSavePath
m
[
"Session
ProviderConfig"
]
=
SessionProviderConfig
m
[
"SessionCookieLifeTime"
]
=
SessionCookieLifeTime
m
[
"
UseFcgi"
]
=
Use
Fcgi
m
[
"
EnabelFcgi"
]
=
Enabel
Fcgi
m
[
"MaxMemory"
]
=
MaxMemory
m
[
"EnableGzip"
]
=
EnableGzip
m
[
"DirectoryIndex"
]
=
DirectoryIndex
m
[
"H
ttpServerTimeOut"
]
=
Http
ServerTimeOut
m
[
"E
rrorsShow"
]
=
ErrorsShow
m
[
"H
TTPServerTimeOut"
]
=
HTTP
ServerTimeOut
m
[
"E
nableErrorsShow"
]
=
Enable
ErrorsShow
m
[
"XSRFKEY"
]
=
XSRFKEY
m
[
"EnableXSRF"
]
=
EnableXSRF
m
[
"XSRFExpire"
]
=
XSRFExpire
...
...
@@ -130,8 +130,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
m
[
"TemplateRight"
]
=
TemplateRight
m
[
"BeegoServerName"
]
=
BeegoServerName
m
[
"EnableAdmin"
]
=
EnableAdmin
m
[
"AdminH
ttpAddr"
]
=
AdminHttp
Addr
m
[
"AdminH
ttpPort"
]
=
AdminHttp
Port
m
[
"AdminH
TTPAddr"
]
=
AdminHTTP
Addr
m
[
"AdminH
TTPPort"
]
=
AdminHTTP
Port
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
configTpl
))
...
...
@@ -451,10 +451,10 @@ func (admin *adminApp) Run() {
if
len
(
toolbox
.
AdminTaskList
)
>
0
{
toolbox
.
StartTask
()
}
addr
:=
AdminH
ttp
Addr
addr
:=
AdminH
TTP
Addr
if
AdminH
ttp
Port
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
AdminH
ttpAddr
,
AdminHttp
Port
)
if
AdminH
TTP
Port
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
AdminH
TTPAddr
,
AdminHTTP
Port
)
}
for
p
,
f
:=
range
admin
.
routers
{
http
.
Handle
(
p
,
f
)
...
...
app.go
View file @
f28a941e
...
...
@@ -52,10 +52,10 @@ func NewApp() *App {
// Run beego application.
func
(
app
*
App
)
Run
()
{
addr
:=
H
ttp
Addr
addr
:=
H
TTP
Addr
if
H
ttp
Port
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
H
ttpAddr
,
Http
Port
)
if
H
TTP
Port
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
H
TTPAddr
,
HTTP
Port
)
}
var
(
...
...
@@ -64,8 +64,8 @@ func (app *App) Run() {
)
endRunning
:=
make
(
chan
bool
,
1
)
if
Use
Fcgi
{
if
Us
eStdIo
{
if
Enabel
Fcgi
{
if
Enabl
eStdIo
{
err
=
fcgi
.
Serve
(
nil
,
app
.
Handlers
)
// standard I/O
if
err
==
nil
{
BeeLogger
.
Info
(
"Use FCGI via standard I/O"
)
...
...
@@ -73,7 +73,7 @@ func (app *App) Run() {
BeeLogger
.
Info
(
"Cannot use FCGI via standard I/O"
,
err
)
}
}
else
{
if
H
ttp
Port
==
0
{
if
H
TTP
Port
==
0
{
// remove the Socket file before start
if
utils
.
FileExists
(
addr
)
{
os
.
Remove
(
addr
)
...
...
@@ -91,18 +91,18 @@ func (app *App) Run() {
if
Graceful
{
app
.
Server
.
Addr
=
addr
app
.
Server
.
Handler
=
app
.
Handlers
app
.
Server
.
ReadTimeout
=
time
.
Duration
(
H
ttp
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
WriteTimeout
=
time
.
Duration
(
H
ttp
ServerTimeOut
)
*
time
.
Second
if
EnableH
ttp
TLS
{
app
.
Server
.
ReadTimeout
=
time
.
Duration
(
H
TTP
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
WriteTimeout
=
time
.
Duration
(
H
TTP
ServerTimeOut
)
*
time
.
Second
if
EnableH
TTP
TLS
{
go
func
()
{
time
.
Sleep
(
20
*
time
.
Microsecond
)
if
H
ttps
Port
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
H
ttpAddr
,
Https
Port
)
if
H
TTPS
Port
!=
0
{
addr
=
fmt
.
Sprintf
(
"%s:%d"
,
H
TTPAddr
,
HTTPS
Port
)
app
.
Server
.
Addr
=
addr
}
server
:=
grace
.
NewServer
(
addr
,
app
.
Handlers
)
server
.
Server
=
app
.
Server
err
:=
server
.
ListenAndServeTLS
(
H
ttpCertFile
,
Http
KeyFile
)
err
:=
server
.
ListenAndServeTLS
(
H
TTPCertFile
,
HTTP
KeyFile
)
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServeTLS: "
,
err
,
fmt
.
Sprintf
(
"%d"
,
os
.
Getpid
()))
time
.
Sleep
(
100
*
time
.
Microsecond
)
...
...
@@ -110,11 +110,11 @@ func (app *App) Run() {
}
}()
}
if
EnableH
ttp
Listen
{
if
EnableH
TTP
Listen
{
go
func
()
{
server
:=
grace
.
NewServer
(
addr
,
app
.
Handlers
)
server
.
Server
=
app
.
Server
if
ListenTCP4
&&
H
ttp
Addr
==
""
{
if
ListenTCP4
&&
H
TTP
Addr
==
""
{
server
.
Network
=
"tcp4"
}
err
:=
server
.
ListenAndServe
()
...
...
@@ -128,17 +128,17 @@ func (app *App) Run() {
}
else
{
app
.
Server
.
Addr
=
addr
app
.
Server
.
Handler
=
app
.
Handlers
app
.
Server
.
ReadTimeout
=
time
.
Duration
(
H
ttp
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
WriteTimeout
=
time
.
Duration
(
H
ttp
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
ReadTimeout
=
time
.
Duration
(
H
TTP
ServerTimeOut
)
*
time
.
Second
app
.
Server
.
WriteTimeout
=
time
.
Duration
(
H
TTP
ServerTimeOut
)
*
time
.
Second
if
EnableH
ttp
TLS
{
if
EnableH
TTP
TLS
{
go
func
()
{
time
.
Sleep
(
20
*
time
.
Microsecond
)
if
H
ttps
Port
!=
0
{
app
.
Server
.
Addr
=
fmt
.
Sprintf
(
"%s:%d"
,
H
ttpAddr
,
Https
Port
)
if
H
TTPS
Port
!=
0
{
app
.
Server
.
Addr
=
fmt
.
Sprintf
(
"%s:%d"
,
H
TTPAddr
,
HTTPS
Port
)
}
BeeLogger
.
Info
(
"https server Running on %s"
,
app
.
Server
.
Addr
)
err
:=
app
.
Server
.
ListenAndServeTLS
(
H
ttpCertFile
,
Http
KeyFile
)
err
:=
app
.
Server
.
ListenAndServeTLS
(
H
TTPCertFile
,
HTTP
KeyFile
)
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServeTLS: "
,
err
)
time
.
Sleep
(
100
*
time
.
Microsecond
)
...
...
@@ -147,11 +147,11 @@ func (app *App) Run() {
}()
}
if
EnableH
ttp
Listen
{
if
EnableH
TTP
Listen
{
go
func
()
{
app
.
Server
.
Addr
=
addr
BeeLogger
.
Info
(
"http server Running on %s"
,
app
.
Server
.
Addr
)
if
ListenTCP4
&&
H
ttp
Addr
==
""
{
if
ListenTCP4
&&
H
TTP
Addr
==
""
{
ln
,
err
:=
net
.
Listen
(
"tcp4"
,
app
.
Server
.
Addr
)
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServe: "
,
err
)
...
...
beego.go
View file @
f28a941e
...
...
@@ -48,10 +48,10 @@ func Run(params ...string) {
if
len
(
params
)
>
0
&&
params
[
0
]
!=
""
{
strs
:=
strings
.
Split
(
params
[
0
],
":"
)
if
len
(
strs
)
>
0
&&
strs
[
0
]
!=
""
{
H
ttp
Addr
=
strs
[
0
]
H
TTP
Addr
=
strs
[
0
]
}
if
len
(
strs
)
>
1
&&
strs
[
1
]
!=
""
{
H
ttp
Port
,
_
=
strconv
.
Atoi
(
strs
[
1
])
H
TTP
Port
,
_
=
strconv
.
Atoi
(
strs
[
1
])
}
}
...
...
config.go
View file @
f28a941e
This diff is collapsed.
Click to expand it.
hooks.go
View file @
f28a941e
...
...
@@ -65,8 +65,8 @@ func registerSession() error {
if
sessionConfig
==
""
{
sessionConfig
=
`{"cookieName":"`
+
SessionName
+
`",`
+
`"gclifetime":`
+
strconv
.
FormatInt
(
SessionGCMaxLifetime
,
10
)
+
`,`
+
`"providerConfig":"`
+
filepath
.
ToSlash
(
Session
SavePath
)
+
`",`
+
`"secure":`
+
strconv
.
FormatBool
(
EnableH
ttp
TLS
)
+
`,`
+
`"providerConfig":"`
+
filepath
.
ToSlash
(
Session
ProviderConfig
)
+
`",`
+
`"secure":`
+
strconv
.
FormatBool
(
EnableH
TTP
TLS
)
+
`,`
+
`"enableSetCookie":`
+
strconv
.
FormatBool
(
SessionAutoSetCookie
)
+
`,`
+
`"domain":"`
+
SessionDomain
+
`",`
+
`"cookieLifeTime":`
+
strconv
.
Itoa
(
SessionCookieLifeTime
)
+
`}`
...
...
router.go
View file @
f28a941e
...
...
@@ -617,7 +617,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if
ok
,
params
:=
filterR
.
ValidRouter
(
urlPath
);
ok
{
for
k
,
v
:=
range
params
{
if
context
.
Input
.
Params
==
nil
{
context
.
Input
.
Params
=
make
(
map
[
string
]
string
)
context
.
Input
.
Params
=
make
(
map
[
string
]
string
)
}
context
.
Input
.
Params
[
k
]
=
v
}
...
...
@@ -869,7 +869,7 @@ func (p *ControllerRegister) recoverPanic(context *beecontext.Context) {
if
!
RecoverPanic
{
panic
(
err
)
}
else
{
if
ErrorsShow
{
if
E
nableE
rrorsShow
{
if
_
,
ok
:=
ErrorMaps
[
fmt
.
Sprint
(
err
)];
ok
{
exception
(
fmt
.
Sprint
(
err
),
context
)
return
...
...
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