authorize: add request id to context (#3497)

* authorize: add request id to context

* fix context keys
This commit is contained in:
Caleb Doxsey 2022-07-26 14:34:48 -06:00 committed by GitHub
parent 06ee1c8711
commit 89a105c8e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 9 deletions

View file

@ -33,11 +33,11 @@ func (nilQuerier) Query(ctx context.Context, in *databroker.QueryRequest, opts .
return nil, status.Error(codes.NotFound, "not found")
}
var querierKey struct{}
type querierKey struct{}
// GetQuerier gets the databroker Querier from the context.
func GetQuerier(ctx context.Context) Querier {
q, ok := ctx.Value(querierKey).(Querier)
q, ok := ctx.Value(querierKey{}).(Querier)
if !ok {
q = nilQuerier{}
}
@ -46,7 +46,7 @@ func GetQuerier(ctx context.Context) Querier {
// WithQuerier sets the databroker Querier on a context.
func WithQuerier(ctx context.Context, querier Querier) context.Context {
return context.WithValue(ctx, querierKey, querier)
return context.WithValue(ctx, querierKey{}, querier)
}
type staticQuerier struct {