From d0eec5fbbfcb0d8d74d608df0518fd03b05e9c4f Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Wed, 13 Sep 2023 21:53:52 +0100 Subject: [PATCH] Update Call ID Middleware Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- gateway/handlers/callid_middleware.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/handlers/callid_middleware.go b/gateway/handlers/callid_middleware.go index a1ddea54f..61a27259b 100644 --- a/gateway/handlers/callid_middleware.go +++ b/gateway/handlers/callid_middleware.go @@ -9,10 +9,14 @@ import ( "time" "github.com/docker/distribution/uuid" + "github.com/openfaas/faas/gateway/version" ) // MakeCallIDMiddleware middleware tags a request with a uid func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc { + + version := version.Version + return func(w http.ResponseWriter, r *http.Request) { start := time.Now() if len(r.Header.Get("X-Call-Id")) == 0 { @@ -24,6 +28,8 @@ func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc { r.Header.Add("X-Start-Time", fmt.Sprintf("%d", start.UTC().UnixNano())) w.Header().Add("X-Start-Time", fmt.Sprintf("%d", start.UTC().UnixNano())) + w.Header().Add("X-Served-By", fmt.Sprintf("openfaas-community/%s", version)) + next(w, r) } }