diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-06-25 15:06:59 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-06-25 15:06:59 +0300 |
commit | b78029c60fe8138fd49aa560b9c4e26279049c5f (patch) | |
tree | 101d25367d9937a64970fa25133f37b797fc78b2 /app.go | |
parent | 947cad46a79aa89323fd10f6d9f2bc16c1f6741d (diff) |
Move custom headers parsing into config loading
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 23 |
1 files changed, 7 insertions, 16 deletions
@@ -48,13 +48,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) { @@ -153,7 +152,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 @@ -369,14 +368,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") } |