Documentation ¶
Overview ¶
Package acceptlang provides a Martini handler and primitives to parse the Accept-Language HTTP header values.
See the HTTP header fields specification for more details (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4).
Example ¶
Use the handler to automatically parse the Accept-Language header and return the results as response:
m.Get("/", acceptlang.Languages(), func(languages acceptlang.AcceptLanguages) string { return fmt.Sprintf("Languages: %s", languages) })
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AcceptLanguage ¶
A single language from the Accept-Language HTTP header.
type AcceptLanguages ¶
type AcceptLanguages []AcceptLanguage
A slice of sortable AcceptLanguage instances.
func (AcceptLanguages) Len ¶
func (al AcceptLanguages) Len() int
Returns the total number of items in the slice. Implemented to satisfy sort.Interface.
func (AcceptLanguages) Less ¶
func (al AcceptLanguages) Less(i, j int) bool
Determines whether or not the item at position i is "less than" the item at position j. Implemented to satisfy sort.Interface.
func (AcceptLanguages) String ¶
func (al AcceptLanguages) String() string
Returns the parsed languages in a human readable fashion.
func (AcceptLanguages) Swap ¶
func (al AcceptLanguages) Swap(i, j int)
Swaps the items at position i and j. Implemented to satisfy sort.Interface.