aboutsummaryrefslogtreecommitdiffstats
path: root/web.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-04-05 15:17:57 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-04-05 15:17:57 +0800
commit493b0c5ac212a28f46938cf8dfb2efb79f658548 (patch)
tree073c9c244dff9a3efe33fb5e02fc71b62e44e327 /web.go
parent75db79b4b6bcb8f61dd957c9bd21b32d4746f866 (diff)
downloadgitea-493b0c5ac212a28f46938cf8dfb2efb79f658548.tar.gz
gitea-493b0c5ac212a28f46938cf8dfb2efb79f658548.zip
add ssl support for web
Diffstat (limited to 'web.go')
-rw-r--r--web.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/web.go b/web.go
index 5fc3350f1f..18e48b84de 100644
--- a/web.go
+++ b/web.go
@@ -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())
+ }
}
}