1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-09 17:32:51 +00:00

adding tls

This commit is contained in:
2016-10-28 21:27:04 +02:00
parent 6848ddadd0
commit 9c2e7bd754
5 changed files with 23 additions and 8 deletions

View File

@@ -24,5 +24,11 @@ func main(){
handle := gziphandler.GzipHandler(route.Routes())
log.Println("Starting Server...")
log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle))
go func(){
log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle))
}()
if configurations.TLSCertFile != "" && configurations.TLSKeyFile != "" {
log.Println(http.ListenAndServeTLS(":"+strconv.Itoa(configurations.TLSPort), configurations.TLSCertFile, configurations.TLSKeyFile, handle))
}
}

View File

@@ -12,9 +12,12 @@ import (
//structure for application configurations
type Config struct {
Database db.DatabaseInfo `json:"database"`
Api api.ApiInfo `json:"api"`
Port int `json:"port"`
Database db.DatabaseInfo `json:"Database"`
Api api.ApiInfo `json:"Api"`
Port int `json:"Port"`
TLSPort int `json:"TLSPort"`
TLSCertFile string `json:"TLSCertFile"`
TLSKeyFile string `json:"TLSKeyFile"`
}
//read the config file and return JsonObject struct