Documentation ¶
Overview ¶
Package accept allows for easy handling of HTTP Accept headers. Accept-Ranges is currently not handled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AcceptSlice ¶
type AcceptSlice []Accept
AcceptSlice is a slice of Accept.
func Parse ¶
func Parse(header string) AcceptSlice
Parse parses a HTTP Accept(-Charset|-Encoding|-Language) header and returns AcceptSlice, sorted in decreasing order of preference. If the header lists multiple types that have the same level of preference (same specificity of type and subtype, same qvalue, and same number of extensions), the type that was listed in the header first comes first in the returned value.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14 for more information.
func (AcceptSlice) Accepts ¶
func (accept AcceptSlice) Accepts(ctype string) bool
Accepts returns true if the provided type is accepted.
func (AcceptSlice) Len ¶
func (a AcceptSlice) Len() int
Len implements the Len() method of the Sort interface.
func (AcceptSlice) Less ¶
func (a AcceptSlice) Less(i, j int) bool
Less implements the Less() method of the Sort interface. Elements are sorted in order of decreasing preference.
func (AcceptSlice) Negotiate ¶
func (accept AcceptSlice) Negotiate(ctypes ...string) (string, error)
Negotiate returns a type that is accepted by both the AcceptSlice, and the list of types provided. If no common types are found, an empty string is returned.
func (AcceptSlice) Swap ¶
func (a AcceptSlice) Swap(i, j int)
Swap implements the Swap() method of the Sort interface.