diff options
Diffstat (limited to 'web.go')
-rw-r--r-- | web.go | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -169,12 +169,22 @@ func runWeb(*cli.Context) { // Not found handler. m.NotFound(routers.NotFound) + protocol := base.Cfg.MustValue("server", "PROTOCOL", "http") listenAddr := fmt.Sprintf("%s:%s", base.Cfg.MustValue("server", "HTTP_ADDR"), base.Cfg.MustValue("server", "HTTP_PORT", "3000")) - log.Info("Listen: %s", listenAddr) - if err := http.ListenAndServe(listenAddr, m); err != nil { - fmt.Println(err.Error()) - //log.Critical(err.Error()) // not working now + + if protocol == "http" { + log.Info("Listen: http://%s", listenAddr) + if err := http.ListenAndServe(listenAddr, m); err != nil { + fmt.Println(err.Error()) + //log.Critical(err.Error()) // not working now + } + } else if protocol == "https" { + log.Info("Listen: https://%s", listenAddr) + if err := http.ListenAndServeTLS(listenAddr, base.Cfg.MustValue("server", "CERT_FILE"), + base.Cfg.MustValue("server", "KEY_FILE"), m); err != nil { + fmt.Println(err.Error()) + } } } |