micro/context/context.go
2015-05-23 11:53:40 +01:00

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)
}