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", "Host": ":8080",
"Encrypted": true, "Encrypted": true,
"SSLHost": ":8090",
"SSLPrivateKey": "/home/ssl.key", "SSLPrivateKey": "/home/ssl.key",
"SSLPublicKey": "/home/ssl.crt", "SSLPublicKey": "/home/ssl.crt",
"Apps": [ "Apps": [
@@ -8,6 +9,7 @@
"ApplicationDisabled": false, "ApplicationDisabled": false,
"Secret": "7ad3753142a6693b25b9", "Secret": "7ad3753142a6693b25b9",
"Key": "278d525bdf162c739803", "Key": "278d525bdf162c739803",
"OnlySSL": false,
"Name": "App 1", "Name": "App 1",
"AppID": "321", "AppID": "321",
"UserEvents": true, "UserEvents": true,
@@ -18,6 +20,7 @@
"ApplicationDisabled": false, "ApplicationDisabled": false,
"Secret": "d6824d2fa32888931504", "Secret": "d6824d2fa32888931504",
"Key": "c8b30f611ffb13202976", "Key": "c8b30f611ffb13202976",
"OnlySSL": false,
"Name": "App 2", "Name": "App 2",
"AppID": "123", "AppID": "123",
"UserEvents": true, "UserEvents": true,
+1
View File
@@ -17,6 +17,7 @@ type configFile struct {
// SSL Configurations // SSL Configurations
Encrypted bool Encrypted bool
SSLHost string
SSLPrivateKey string SSLPrivateKey string
SSLPublicKey string SSLPublicKey string
+6 -1
View File
@@ -32,7 +32,12 @@ func Start(configfile string) error {
router := newRouter() router := newRouter()
if conf.Encrypted { 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 return err
} }
}else{ }else{