Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
4cd55875c6
commit
19b04fe070
@ -67,6 +67,22 @@ func (md Metadata) Iterator() *Iterator {
|
|||||||
return iter
|
return iter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (md Metadata) MustGet(key string) string {
|
||||||
|
// fast path
|
||||||
|
val, ok := md[key]
|
||||||
|
if !ok {
|
||||||
|
// slow path
|
||||||
|
val, ok = md[textproto.CanonicalMIMEHeaderKey(key)]
|
||||||
|
if !ok {
|
||||||
|
val, ok = md[strings.ToLower(key)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
panic("missing metadata key")
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns value from metadata by key
|
// Get returns value from metadata by key
|
||||||
func (md Metadata) Get(key string) (string, bool) {
|
func (md Metadata) Get(key string) (string, bool) {
|
||||||
// fast path
|
// fast path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user