insert request id in context
Some checks failed
codeql / analyze (go) (pull_request) Failing after 3m15s
dependabot-automerge / automerge (pull_request) Has been skipped
prbuild / test (pull_request) Failing after 1m29s
prbuild / lint (pull_request) Failing after 2m37s
autoapprove / autoapprove (pull_request) Failing after 1m26s
automerge / automerge (pull_request) Failing after 4s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2023-08-23 16:30:47 +03:00
parent 74ee3bbbf1
commit d03bf1aa14

View File

@ -10,6 +10,8 @@ import (
"go.unistack.org/micro/v3/util/id" "go.unistack.org/micro/v3/util/id"
) )
var XRequestIDKey struct{}
// DefaultMetadataKey contains metadata key // DefaultMetadataKey contains metadata key
var DefaultMetadataKey = textproto.CanonicalMIMEHeaderKey("x-request-id") var DefaultMetadataKey = textproto.CanonicalMIMEHeaderKey("x-request-id")
@ -40,7 +42,8 @@ var DefaultMetadataFunc = func(ctx context.Context) (context.Context, error) {
omd.Set(DefaultMetadataKey, v) omd.Set(DefaultMetadataKey, v)
ctx = metadata.NewIncomingContext(ctx, imd) ctx = metadata.NewIncomingContext(ctx, imd)
ctx = metadata.NewOutgoingContext(ctx, omd) ctx = metadata.NewOutgoingContext(ctx, omd)
return ctx, nil
return context.WithValue(ctx, XRequestIDKey, v), nil
} }
type wrapper struct { type wrapper struct {