Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'app.go')
-rw-r--r--app.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/app.go b/app.go
index 08e82042..a3fc8335 100644
--- a/app.go
+++ b/app.go
@@ -2,15 +2,18 @@ package main
import (
"crypto/tls"
+ "log"
"net/http"
"strings"
"sync"
+ "time"
)
const xForwardedProto = "X-Forwarded-Proto"
const xForwardedProtoHTTPS = "https"
type theApp struct {
+ appConfig
domains domains
lock sync.RWMutex
}
@@ -78,3 +81,46 @@ func (a *theApp) UpdateDomains(domains domains) {
defer a.lock.Unlock()
a.domains = domains
}
+
+func (a *theApp) Run() {
+ var wg sync.WaitGroup
+
+ if a.ListenHTTP != 0 {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ err := listenAndServe(a.ListenHTTP, a.ServeHTTP, nil)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }()
+ }
+
+ // Listen for HTTPS
+ if a.ListenHTTPS != 0 {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ err := listenAndServeTLS(a.ListenHTTPS, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }()
+ }
+
+ // Listen for HTTP proxy requests
+ if a.listenProxy != 0 {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ err := listenAndServe(a.listenProxy, a.ServeProxy, nil)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }()
+ }
+
+ go watchDomains(a.UpdateDomains, time.Second)
+
+ wg.Wait()
+}