diff options
author | Ercan Ucan <ercan.ucan@siemens.com> | 2021-02-23 18:35:37 +0300 |
---|---|---|
committer | Ercan Ucan <ercan.ucan@siemens.com> | 2021-02-24 17:37:16 +0300 |
commit | ae9a8fb5304fca0a1dc0441cb991227320033bca (patch) | |
tree | 0ca630df4863298dba0a2f493e91f58b94deda99 /app.go | |
parent | 808300edb233f751aa6bb6abc8275774ffce936e (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.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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 |