mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 14:23:25 +00:00
Don't override X-Call-Id if it already exists in header
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
@ -12,9 +12,11 @@ import (
|
||||
func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
callID := uuid.Generate().String()
|
||||
r.Header.Add("X-Call-Id", callID)
|
||||
w.Header().Add("X-Call-Id", callID)
|
||||
if len(r.Header.Get("X-Call-Id")) == 0 {
|
||||
callID := uuid.Generate().String()
|
||||
r.Header.Add("X-Call-Id", callID)
|
||||
w.Header().Add("X-Call-Id", callID)
|
||||
}
|
||||
|
||||
r.Header.Add("X-Start-Time", fmt.Sprintf("%d", start.UTC().UnixNano()))
|
||||
w.Header().Add("X-Start-Time", fmt.Sprintf("%d", start.UTC().UnixNano()))
|
||||
|
Reference in New Issue
Block a user