opentracing/grpc fix: properly encode metadata key-value pairs
Bas van Beek
7 years ago
0 | 0 | package opentracing |
1 | 1 | |
2 | 2 | import ( |
3 | "encoding/base64" | |
4 | "strings" | |
5 | ||
3 | 6 | "github.com/opentracing/opentracing-go" |
4 | 7 | "golang.org/x/net/context" |
5 | 8 | "google.golang.org/grpc/metadata" |
52 | 55 | } |
53 | 56 | |
54 | 57 | func (w metadataReaderWriter) Set(key, val string) { |
58 | key = strings.ToLower(key) | |
59 | if strings.HasSuffix(key, "-bin") { | |
60 | val = string(base64.StdEncoding.EncodeToString([]byte(val))) | |
61 | } | |
55 | 62 | (*w.MD)[key] = append((*w.MD)[key], val) |
56 | 63 | } |
57 | 64 |