fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
9dd64b1d81
commit
4fa0b2c82c
@ -152,27 +152,24 @@ func ContentType(ct string) Option {
|
||||
|
||||
// Metadata pass additional metadata
|
||||
func Metadata(md ...any) Option {
|
||||
result := metadata.Metadata{}
|
||||
|
||||
if len(md) > 1 {
|
||||
var tmp []string
|
||||
for _, val := range md {
|
||||
switch vt := val.(type) {
|
||||
case string:
|
||||
tmp = append(tmp, vt)
|
||||
default:
|
||||
return func(src interface{}) error {
|
||||
return Set(src, result, ".Metadata")
|
||||
}
|
||||
}
|
||||
}
|
||||
result.Set(tmp...)
|
||||
} else if len(md) == 1 {
|
||||
var result metadata.Metadata
|
||||
if len(md) == 1 {
|
||||
switch vt := md[0].(type) {
|
||||
case metadata.Metadata:
|
||||
result = metadata.Copy(vt)
|
||||
case map[string]string:
|
||||
result = metadata.Copy(vt)
|
||||
default:
|
||||
result = metadata.New(0)
|
||||
}
|
||||
} else {
|
||||
result = metadata.New(len(md) / 2)
|
||||
for idx := 0; idx < len(md)/2; idx += 2 {
|
||||
k, kok := md[idx].(string)
|
||||
v, vok := md[idx+1].(string)
|
||||
if kok && vok {
|
||||
result.Set(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user