Both server running. SSL and Non SSL

This commit is contained in:
Welington Sampaio
2016-03-03 14:54:53 -03:00
parent 051da185e5
commit e93145efe7
3 changed files with 10 additions and 1 deletions
+3
View File
@@ -1,6 +1,7 @@
{
"Host": ":8080",
"Encrypted": true,
"SSLHost": ":8090",
"SSLPrivateKey": "/home/ssl.key",
"SSLPublicKey": "/home/ssl.crt",
"Apps": [
@@ -8,6 +9,7 @@
"ApplicationDisabled": false,
"Secret": "7ad3753142a6693b25b9",
"Key": "278d525bdf162c739803",
"OnlySSL": false,
"Name": "App 1",
"AppID": "321",
"UserEvents": true,
@@ -18,6 +20,7 @@
"ApplicationDisabled": false,
"Secret": "d6824d2fa32888931504",
"Key": "c8b30f611ffb13202976",
"OnlySSL": false,
"Name": "App 2",
"AppID": "123",
"UserEvents": true,
+1
View File
@@ -17,6 +17,7 @@ type configFile struct {
// SSL Configurations
Encrypted bool
SSLHost string
SSLPrivateKey string
SSLPublicKey string
+6 -1
View File
@@ -32,7 +32,12 @@ func Start(configfile string) error {
router := newRouter()
if conf.Encrypted {
if err := http.ListenAndServeTLS(conf.Host, conf.SSLPublicKey, conf.SSLPrivateKey, router); err != nil {
go func () {
if err := http.ListenAndServe(conf.Host, router); err != nil {
return err
}
}
if err := http.ListenAndServeTLS(conf.SSLHost, conf.SSLPublicKey, conf.SSLPrivateKey, router); err != nil {
return err
}
}else{