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
18a02d7d
Commit
18a02d7d
authored
May 20, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego:support https & http listen
parent
3f4d750d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
13 deletions
+43
-13
admin.go
admin.go
+1
-1
app.go
app.go
+25
-8
beego.go
beego.go
+1
-1
config.go
config.go
+16
-3
No files found.
admin.go
View file @
18a02d7d
...
...
@@ -88,7 +88,7 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
fmt
.
Fprintln
(
rw
,
"StaticExtensionsToGzip:"
,
StaticExtensionsToGzip
)
fmt
.
Fprintln
(
rw
,
"HttpAddr:"
,
HttpAddr
)
fmt
.
Fprintln
(
rw
,
"HttpPort:"
,
HttpPort
)
fmt
.
Fprintln
(
rw
,
"HttpTLS:"
,
HttpTLS
)
fmt
.
Fprintln
(
rw
,
"HttpTLS:"
,
Enable
HttpTLS
)
fmt
.
Fprintln
(
rw
,
"HttpCertFile:"
,
HttpCertFile
)
fmt
.
Fprintln
(
rw
,
"HttpKeyFile:"
,
HttpKeyFile
)
fmt
.
Fprintln
(
rw
,
"RecoverPanic:"
,
RecoverPanic
)
...
...
app.go
View file @
18a02d7d
...
...
@@ -45,6 +45,7 @@ func (app *App) Run() {
err
error
l
net
.
Listener
)
endRunning
:=
make
(
chan
bool
)
if
UseFcgi
{
if
HttpPort
==
0
{
...
...
@@ -83,18 +84,34 @@ func (app *App) Run() {
ReadTimeout
:
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
,
WriteTimeout
:
time
.
Duration
(
HttpServerTimeOut
)
*
time
.
Second
,
}
if
HttpTLS
{
err
=
s
.
ListenAndServeTLS
(
HttpCertFile
,
HttpKeyFile
)
}
else
{
err
=
s
.
ListenAndServe
()
if
EnableHttpTLS
{
go
func
()
{
if
HttpsPort
!=
0
{
s
.
Addr
=
fmt
.
Sprintf
(
"%s:%d"
,
HttpAddr
,
HttpsPort
)
}
err
:=
s
.
ListenAndServeTLS
(
HttpCertFile
,
HttpKeyFile
)
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServe: "
,
err
)
time
.
Sleep
(
100
*
time
.
Microsecond
)
endRunning
<-
true
}
}()
}
if
EnableHttpListen
{
go
func
()
{
err
:=
s
.
ListenAndServe
()
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServe: "
,
err
)
time
.
Sleep
(
100
*
time
.
Microsecond
)
endRunning
<-
true
}
}()
}
}
}
if
err
!=
nil
{
BeeLogger
.
Critical
(
"ListenAndServe: "
,
err
)
time
.
Sleep
(
100
*
time
.
Microsecond
)
}
<-
endRunning
}
// Router adds a url-patterned controller handler.
...
...
beego.go
View file @
18a02d7d
...
...
@@ -270,7 +270,7 @@ func initBeforeHttpRun() {
sessionConfig
=
`{"cookieName":"`
+
SessionName
+
`",`
+
`"gclifetime":`
+
strconv
.
FormatInt
(
SessionGCMaxLifetime
,
10
)
+
`,`
+
`"providerConfig":"`
+
SessionSavePath
+
`",`
+
`"secure":`
+
strconv
.
FormatBool
(
HttpTLS
)
+
`,`
+
`"secure":`
+
strconv
.
FormatBool
(
Enable
HttpTLS
)
+
`,`
+
`"sessionIDHashFunc":"`
+
SessionHashFunc
+
`",`
+
`"sessionIDHashKey":"`
+
SessionHashKey
+
`",`
+
`"enableSetCookie":`
+
strconv
.
FormatBool
(
SessionAutoSetCookie
)
+
`,`
+
...
...
config.go
View file @
18a02d7d
...
...
@@ -30,9 +30,11 @@ var (
StaticDir
map
[
string
]
string
TemplateCache
map
[
string
]
*
template
.
Template
// template caching map
StaticExtensionsToGzip
[]
string
// files with should be compressed with gzip (.js,.css,etc)
EnableHttpListen
bool
HttpAddr
string
HttpPort
int
HttpTLS
bool
EnableHttpTLS
bool
HttpsPort
int
HttpCertFile
string
HttpKeyFile
string
RecoverPanic
bool
// flag of auto recover panic
...
...
@@ -98,9 +100,12 @@ func init() {
TemplateCache
=
make
(
map
[
string
]
*
template
.
Template
)
// set this to 0.0.0.0 to make this app available to externally
EnableHttpListen
=
true
//default enable http Listen
HttpAddr
=
""
HttpPort
=
8080
HttpsPort
=
443
AppName
=
"beego"
RunMode
=
"dev"
//default runmod
...
...
@@ -176,6 +181,10 @@ func ParseConfig() (err error) {
HttpPort
=
v
}
if
v
,
err
:=
AppConfig
.
Bool
(
"EnableHttpListen"
);
err
==
nil
{
EnableHttpListen
=
v
}
if
maxmemory
,
err
:=
AppConfig
.
Int64
(
"MaxMemory"
);
err
==
nil
{
MaxMemory
=
maxmemory
}
...
...
@@ -281,8 +290,12 @@ func ParseConfig() (err error) {
TemplateRight
=
tplright
}
if
httptls
,
err
:=
AppConfig
.
Bool
(
"HttpTLS"
);
err
==
nil
{
HttpTLS
=
httptls
if
httptls
,
err
:=
AppConfig
.
Bool
(
"EnableHttpTLS"
);
err
==
nil
{
EnableHttpTLS
=
httptls
}
if
httpsport
,
err
:=
AppConfig
.
Int
(
"HttpsPort"
);
err
==
nil
{
HttpsPort
=
httpsport
}
if
certfile
:=
AppConfig
.
String
(
"HttpCertFile"
);
certfile
!=
""
{
...
...
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