Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatch = &InvalidArgumentError{Message: "no matching header found"}
ErrNoMatch is returned when no matching header is found.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
// Value is the original header value.
Value string
// Type is the accept type (e.g., "text/html", "en", "utf-8").
Type string
// Quality is the quality value (q-value), defaulting to 1.0.
Quality float64
// Parameters contains all parameters except 'q'.
Parameters map[string]string
// BasePart is the base part (e.g., "text" from "text/html", "en" from "en-US").
// Empty for types that don't use base/sub parts.
BasePart string
// SubPart is the sub part (e.g., "html" from "text/html", "US" from "en-US").
// Empty for types that don't use base/sub parts.
SubPart string
// NormalizedValue is the normalized value with sorted parameters.
NormalizedValue string
// contains filtered or unexported fields
}
Header represents a parsed Accept* header value. Fields are exported for direct access (idiomatic Go).
type InvalidArgumentError ¶
type InvalidArgumentError struct {
Message string
}
InvalidArgumentError is returned when an invalid argument is provided.
func (*InvalidArgumentError) Error ¶
func (e *InvalidArgumentError) Error() string
type InvalidHeaderError ¶
type InvalidHeaderError struct {
Header string
}
InvalidHeaderError is returned when a header cannot be parsed.
func (*InvalidHeaderError) Error ¶
func (e *InvalidHeaderError) Error() string
type InvalidLanguageError ¶
type InvalidLanguageError struct{}
InvalidLanguageError is returned when a language tag is invalid.
func (*InvalidLanguageError) Error ¶
func (e *InvalidLanguageError) Error() string
type InvalidMediaTypeError ¶
type InvalidMediaTypeError struct{}
InvalidMediaTypeError is returned when a media type is invalid.
func (*InvalidMediaTypeError) Error ¶
func (e *InvalidMediaTypeError) Error() string
type Negotiator ¶
type Negotiator struct {
// contains filtered or unexported fields
}
Negotiator handles all negotiation logic.
func NewCharsetNegotiator ¶
func NewCharsetNegotiator() *Negotiator
NewCharsetNegotiator creates a new Negotiator for charsets.
func NewEncodingNegotiator ¶
func NewEncodingNegotiator() *Negotiator
NewEncodingNegotiator creates a new Negotiator for encodings.
func NewLanguageNegotiator ¶
func NewLanguageNegotiator() *Negotiator
NewLanguageNegotiator creates a new Negotiator for languages.
func NewMediaNegotiator ¶
func NewMediaNegotiator() *Negotiator
NewMediaNegotiator creates a new Negotiator for media types.
func (*Negotiator) GetOrderedElements ¶
func (c *Negotiator) GetOrderedElements(header string) ([]*Header, error)
GetOrderedElements returns all accept header elements ordered by quality.