acceptlang: Index | Files

package acceptlang

import ""

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 (


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)


Package Files


func Languages Uses

func Languages() martini.Handler

Creates a new handler that parses the Accept-Language HTTP header.

The parsed structure is a slice of Accept-Language values stored in an AcceptLanguages instance, sorted based on the language qualifier.

type AcceptLanguage Uses

type AcceptLanguage struct {
    Language string
    Quality  float32

A single language from the Accept-Language HTTP header.

type AcceptLanguages Uses

type AcceptLanguages []AcceptLanguage

A slice of sortable AcceptLanguage instances.

func (AcceptLanguages) Len Uses

func (al AcceptLanguages) Len() int

Returns the total number of items in the slice. Implemented to satisfy sort.Interface.

func (AcceptLanguages) Less Uses

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 Uses

func (al AcceptLanguages) String() string

Returns the parsed languages in a human readable fashion.

func (AcceptLanguages) Swap Uses

func (al AcceptLanguages) Swap(i, j int)

Swaps the items at position i and j. Implemented to satisfy sort.Interface.

Package acceptlang imports 7 packages (graph) and is imported by 2 packages. Updated 2016-07-19. Refresh now. Tools for package owners.