Documentation
¶
Overview ¶
Package negotiate provides HTTP content negotiation utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accept ¶
Accept returns the best matching offer based on the Accept header value. Returns "" if no offer matches. Matching is case-insensitive per RFC 9110, but the original offer string is returned. Entries with q=0 are treated as "not acceptable" per RFC 9110 §12.5.1 and exclude matching offers even from wildcard entries.
func MatchMedia ¶
MatchMedia returns true if the Accept pattern matches the offered media type. Supports wildcards: "*" or "*/*" matches everything, "text/*" matches any text subtype. Comparison is case-insensitive per RFC 9110.
Types ¶
type AcceptItem ¶
AcceptItem represents a parsed Accept header entry with media type and quality.
func Parse ¶
func Parse(header string) []AcceptItem
Parse parses an Accept header value into a slice of AcceptItems. MediaType values are lowercased for case-insensitive matching.