1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-08-04 21:42:57 +02:00

Add metadata Get method (#1425)

This commit is contained in:
Asim Aslam
2020-03-26 18:50:00 +00:00
committed by GitHub
parent 329bd09f93
commit e204f3e2e8
2 changed files with 15 additions and 3 deletions

View File

@ -13,6 +13,18 @@ type metaKey struct{}
// from Transport headers.
type Metadata map[string]string
func (md Metadata) Get(key string) (string, bool) {
// attempt to get as is
val, ok := md[key]
if ok {
return val, ok
}
// attempt to get lower case
val, ok = md[strings.Title(key)]
return val, ok
}
// Copy makes a copy of the metadata
func Copy(md Metadata) Metadata {
cmd := make(Metadata)