Пример #1
0
// Keys returns a list of header keys defined on this Headers object.
//
// All items in the list will be normalized using CanonicalizeHeaderKey.
func (h Headers) Keys() []string {
	ih := internal.Headers(h)
	keys := make([]string, 0, ih.Len())
	for k := range ih.Items() {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	return keys
}
Пример #2
0
// Items returns the underlying map for this Headers map.
//
// Keys in the map are normalized using CanonicalizeHeaderKey.
//
// The returned map MUST NOT be mutated.
func (h Headers) Items() map[string]string {
	return internal.Headers(h).Items()
}
Пример #3
0
// Len returns the number of headers defined on this object.
func (h Headers) Len() int {
	return internal.Headers(h).Len()
}
Пример #4
0
// Get retrieves the value associated with the given header name.
func (h Headers) Get(k string) (string, bool) {
	return internal.Headers(h).Get(k)
}
Пример #5
0
// Del deletes the header with the given name from the Headers map.
//
// This is a no-op if the key does not exist.
func (h Headers) Del(k string) {
	internal.Headers(h).Del(k)
}
Пример #6
0
// With returns a Headers object with the given key-value pair added to it.
// The returned object MAY not point to the same Headers underlying data store
// as the original Headers so the returned Headers MUST always be used instead
// of the original object.
//
// 	headers = headers.With("foo", "bar").With("baz", "qux")
func (h Headers) With(k, v string) Headers {
	return Headers(internal.Headers(h).With(k, v))
}