Skip to content
Snippets Groups Projects
Commit dc37d131 authored by Alex Ellis's avatar Alex Ellis
Browse files

Don't override X-Call-Id if it already exists in header


Signed-off-by: default avatarAlex Ellis <alexellis2@gmail.com>
parent b1e92f6b
No related branches found
No related tags found
No related merge requests found
......@@ -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()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment