header

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(name string) (string, error)

Key returns the case-insensitive identity of a valid header name.

func Present

func Present(src map[string][]string, name string) bool

Present reports whether name carries a non-blank value in src.

func Valid

func Valid(name string) bool

Valid reports whether name is an HTTP field-name token. Whitespace is never trimmed: callers must decide whether trimming belongs at their own boundary.

func Value

func Value(src map[string][]string, name string) string

Value returns the first non-blank value stored under name. Keys are matched case-insensitively and are never canonicalized, so a block written straight into the map answers the same way one built with the http.Header setters does.

Types

type CollisionError

type CollisionError struct {
	First  string
	Second string
}

CollisionError reports header names with the same case-insensitive identity.

func (*CollisionError) Error

func (e *CollisionError) Error() string

type Name

type Name struct {
	// contains filtered or unexported fields
}

Name is a validated, case-insensitive HTTP field name. Its zero value is not a valid name.

func Parse

func Parse(name string) (Name, error)

Parse validates name and returns its case-insensitive identity.

func (Name) Key

func (n Name) Key() string

Key returns the normalized identity of n.

type NameError

type NameError struct {
	Name string
}

NameError reports a string that is not an HTTP field name.

func (*NameError) Error

func (e *NameError) Error() string

type Named

type Named struct {
	Source string
	Name   Name
}

Named contains a header name and its case-insensitive identity.

func Keys

func Keys[V any](src map[string]V) ([]Named, error)

Keys validates and sorts the names in src. It rejects names with the same case-insensitive identity so map iteration cannot choose which value wins. Sorting also makes validation errors deterministic.

type Values

type Values map[string][]string

Values is a header block. Every entry is represented as a list, including entries with zero or one value.

func Normalize

func Normalize(src map[string][]string) (Values, error)

Normalize validates names, rejects equivalent forms, copies every value list, and keys the result by header identity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL