Merge branch '12430-output-glob'
[arvados.git] / sdk / go / arvados / context.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import (
8         "context"
9 )
10
11 type contextKeyRequestID struct{}
12 type contextKeyAuthorization struct{}
13
14 func ContextWithRequestID(ctx context.Context, reqid string) context.Context {
15         return context.WithValue(ctx, contextKeyRequestID{}, reqid)
16 }
17
18 // ContextWithAuthorization returns a child context that (when used
19 // with (*Client)RequestAndDecodeContext) sends the given
20 // Authorization header value instead of the Client's default
21 // AuthToken.
22 func ContextWithAuthorization(ctx context.Context, value string) context.Context {
23         return context.WithValue(ctx, contextKeyAuthorization{}, value)
24 }