diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2022-07-04 06:42:16 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2022-07-04 06:42:16 +0300 |
commit | 62a0ed16b565fbae849ede567eda9d06d22470ea (patch) | |
tree | 8e2f42f4ecc347b53860124086eacd4d25a9bd4e /app.go | |
parent | 79e339d31c7770e73d3f54b63d3675d3604c3b0d (diff) | |
parent | b78029c60fe8138fd49aa560b9c4e26279049c5f (diff) |
Merge branch 'refactor/custom-headers-parsing' into 'master'
refactor: move custom headers parsing into config loading
See merge request gitlab-org/gitlab-pages!801
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 23 |
1 files changed, 7 insertions, 16 deletions
@@ -49,13 +49,12 @@ var ( ) type theApp struct { - config *cfg.Config - source source.Source - tlsConfig *cryptotls.Config - Artifact *artifact.Artifact - Auth *auth.Auth - Handlers *handlers.Handlers - CustomHeaders http.Header + config *cfg.Config + source source.Source + tlsConfig *cryptotls.Config + Artifact *artifact.Artifact + Auth *auth.Auth + Handlers *handlers.Handlers } func (a *theApp) GetCertificate(ch *cryptotls.ClientHelloInfo) (*cryptotls.Certificate, error) { @@ -154,7 +153,7 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) { handler = health.NewMiddleware(handler, a.config.General.StatusPath) // Custom response headers - handler = customheaders.NewMiddleware(handler, a.CustomHeaders) + handler = customheaders.NewMiddleware(handler, a.config.General.CustomHeaders) // Correlation ID injection middleware var correlationOpts []correlation.InboundHandlerOption @@ -372,14 +371,6 @@ func runApp(config *cfg.Config) error { a.Handlers = handlers.New(a.Auth, a.Artifact) - if len(config.General.CustomHeaders) != 0 { - customHeaders, err := customheaders.ParseHeaderString(config.General.CustomHeaders) - if err != nil { - return fmt.Errorf("unable to parse header string: %w", err) - } - a.CustomHeaders = customHeaders - } - if err := mimedb.LoadTypes(); err != nil { log.WithError(err).Warn("Loading extended MIME database failed") } |