You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
471 B

11 months ago
package mapping
import (
"net/http"
"net/textproto"
)
const headerKey = "header"
var headerUnmarshaler = NewUnmarshaler(headerKey, WithStringValues(),
WithCanonicalKeyFunc(textproto.CanonicalMIMEHeaderKey))
// ParseHeaders parses the headers request.
func ParseHeaders(header http.Header, v any) error {
m := map[string]any{}
for k, v := range header {
if len(v) == 1 {
m[k] = v[0]
} else {
m[k] = v
}
}
return headerUnmarshaler.Unmarshal(m, v)
}