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:
authorErcan Ucan <ercan.ucan@siemens.com>2021-02-23 18:35:37 +0300
committerErcan Ucan <ercan.ucan@siemens.com>2021-02-24 17:37:16 +0300
commitae9a8fb5304fca0a1dc0441cb991227320033bca (patch)
tree0ca630df4863298dba0a2f493e91f58b94deda99 /app.go
parent808300edb233f751aa6bb6abc8275774ffce936e (diff)
fix: use correlationID middleware
As discussed within https://gitlab.com/gitlab-org/gitlab-pages/-/issues/510 this MR adds the usage of labkit's correlationID middleware. It uses a similar approach to the implemantion in gitlab-workhorse. Fixes https://gitlab.com/gitlab-org/gitlab-pages/-/issues/510 :tools: with :heart: at Siemens Changelog: fixed
Diffstat (limited to 'app.go')
-rw-r--r--app.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/app.go b/app.go
index 0a6f0cd4..40bfd153 100644
--- a/app.go
+++ b/app.go
@@ -15,6 +15,7 @@ import (
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/go-mimedb"
+ "gitlab.com/gitlab-org/labkit/correlation"
"gitlab.com/gitlab-org/labkit/errortracking"
labmetrics "gitlab.com/gitlab-org/labkit/metrics"
"gitlab.com/gitlab-org/labkit/monitoring"
@@ -339,6 +340,13 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) {
// Custom response headers
handler = a.customHeadersMiddleware(handler)
+ // Correlation ID injection middleware
+ var correlationOpts []correlation.InboundHandlerOption
+ if a.appConfig.PropagateCorrelationID {
+ correlationOpts = append(correlationOpts, correlation.WithPropagation())
+ }
+ handler = correlation.InjectCorrelationID(handler, correlationOpts...)
+
// This MUST be the last handler!
// This handler blocks unknown HTTP methods,
// being the last means it will be evaluated first