Skip to content

Commit

Permalink
Merge pull request #2 from eltorocorp/ContextWithID
Browse files Browse the repository at this point in the history
add a function which build a context with a custom id as the value an…
  • Loading branch information
dsegundo2 authored Apr 22, 2022
2 parents 7160ef7 + 8124ddf commit a939f51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xrequestid/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ func FromContext(ctx context.Context) string {
}
return id
}

// Create a context with the private requestIDKey{} for testing
func ContextWithID(ctx context.Context, requestID string) context.Context {
return context.WithValue(ctx, requestIDKey{}, requestID)
}

0 comments on commit a939f51

Please sign in to comment.