1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
go-micro/context/context.go

23 lines
359 B
Go

package context
import (
"golang.org/x/net/context"
)
type key int
const (
mdKey = key(0)
)
type Metadata map[string]string
func GetMetadata(ctx context.Context) (Metadata, bool) {
md, ok := ctx.Value(mdKey).(Metadata)
return md, ok
}
func WithMetadata(ctx context.Context, md Metadata) context.Context {
return context.WithValue(ctx, mdKey, md)
}