diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-04-05 15:17:57 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-04-05 15:17:57 +0800 |
commit | 493b0c5ac212a28f46938cf8dfb2efb79f658548 (patch) | |
tree | 073c9c244dff9a3efe33fb5e02fc71b62e44e327 /web.go | |
parent | 75db79b4b6bcb8f61dd957c9bd21b32d4746f866 (diff) | |
download | gitea-493b0c5ac212a28f46938cf8dfb2efb79f658548.tar.gz gitea-493b0c5ac212a28f46938cf8dfb2efb79f658548.zip |
add ssl support for web
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()) + } } } |