blob: 2443c58268edc06831070fc4d6135fdc462128ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package featureflag
import (
"context"
"google.golang.org/grpc/metadata"
)
// EnableFeatureFlag is used in tests to enablea a feature flag in the context metadata
func EnableFeatureFlag(ctx context.Context, flag string) context.Context {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
md = metadata.New(map[string]string{HeaderKey(flag): "true"})
} else {
md.Set(HeaderKey(flag), "true")
}
return metadata.NewOutgoingContext(context.Background(), md)
}
|