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:
authorJ. Shuster <joshuagregoryshuster@gmail.com>2017-09-08 11:58:42 +0300
committerNick Thomas <nick@gitlab.com>2017-09-08 11:58:42 +0300
commit0a144bc6055b41fac726fdc6eeaa7150f622bd20 (patch)
tree9ed2a4dbecbd8146245ae8fa609cd9f54d038bf6 /app.go
parent0173d4e6b6b17443155d121a9098d0e742b9c4e3 (diff)
Add an artifacts proxy to GitLab Pages
Diffstat (limited to 'app.go')
-rw-r--r--app.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/app.go b/app.go
index 61b1176c..3714582a 100644
--- a/app.go
+++ b/app.go
@@ -14,6 +14,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/cors"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/artifact"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/metrics"
)
@@ -26,8 +28,9 @@ var (
type theApp struct {
appConfig
- domains domains
- lock sync.RWMutex
+ domains domains
+ lock sync.RWMutex
+ Artifact *artifact.Artifact
}
func (a *theApp) domain(host string) *domain {
@@ -79,9 +82,16 @@ func (a *theApp) serveContent(ww http.ResponseWriter, r *http.Request, https boo
if err != nil {
host = r.Host
}
+
+ // In the event a host is prefixed with the artifact prefix an artifact
+ // value is created, and an attempt to proxy the request is made
+ if a.Artifact.TryMakeRequest(host, &w, r) {
+ return
+ }
+
domain := a.domain(host)
if domain == nil {
- serve404(&w)
+ httperrors.Serve404(&w)
return
}
@@ -173,5 +183,9 @@ func (a *theApp) Run() {
func runApp(config appConfig) {
a := theApp{appConfig: config}
+
+ if config.ArtifactsServer != "" {
+ a.Artifact = artifact.New(config.ArtifactsServer, config.ArtifactsServerTimeout, config.Domain)
+ }
a.Run()
}