|
@@ -9,6 +9,18 @@ import (
|
|
|
|
|
|
|
|
func AppendToContext(ctx context.Context, key string, value interface{}) context.Context {
|
|
func AppendToContext(ctx context.Context, key string, value interface{}) context.Context {
|
|
|
ctx = context.WithValue(ctx, key, value)
|
|
ctx = context.WithValue(ctx, key, value)
|
|
|
- ctx = metadata.AppendToOutgoingContext(ctx, key, fmt.Sprint(value))
|
|
|
|
|
|
|
+ _value := ""
|
|
|
|
|
+ switch value.(type) {
|
|
|
|
|
+ case []byte:
|
|
|
|
|
+ _value = string(value.([]byte))
|
|
|
|
|
+ break
|
|
|
|
|
+ case string:
|
|
|
|
|
+ _value = value.(string)
|
|
|
|
|
+ break
|
|
|
|
|
+ default:
|
|
|
|
|
+ _value = fmt.Sprint(value)
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx = metadata.AppendToOutgoingContext(ctx, key, _value)
|
|
|
return ctx
|
|
return ctx
|
|
|
}
|
|
}
|