github.com/mier85/go-sensor@v1.30.1-0.20220920111756-9bf41b3bc7e0/w3ctrace/middleware.go (about) 1 // (c) Copyright IBM Corp. 2021 2 // (c) Copyright Instana Inc. 2020 3 4 package w3ctrace 5 6 import "net/http" 7 8 // TracingHandlerFunc is an HTTP middleware that forwards the W3C context found in request 9 // with the response 10 func TracingHandlerFunc(handler http.HandlerFunc) http.HandlerFunc { 11 return func(w http.ResponseWriter, req *http.Request) { 12 if trCtx, err := Extract(req.Header); err == nil { 13 Inject(trCtx, w.Header()) 14 } 15 16 handler(w, req) 17 } 18 }