package
0.0.0-20140208234550-8ce6181c2609
Repository: https://github.com/codegangsta/martini-contrib.git
Documentation: pkg.go.dev

# README

acceptlang

Using the acceptlang handler you can automatically parse the Accept-Language HTTP header and expose it as an AcceptLanguages slice in your handler functions. The AcceptLanguages slice contains AcceptLanguage values, each of which represent a qualified (or unqualified) language. The values in the slice are sorted descending by qualification (the most qualified languages will have the lowest indexes in the slice).

Unqualified languages are interpreted as having the maximum qualification of 1, as defined in the HTTP/1.1 specification.

For more information:

Usage

Simply add a new handler function instance to your handler chain using the acceptlang.Languages() function as well as an AcceptLanguages dependency in your handler function. The AcceptLanguages dependency will be satisified by the handler.

For example:

package main

import (
	"fmt"
	"github.com/codegangsta/martini"
	"github.com/codegangsta/martini-contrib/acceptlang"
	"net/http"
)

func main() {
	m := martini.Classic()

	m.Get("/", acceptlang.Languages(), func(languages acceptlang.AcceptLanguages) string {
		return fmt.Sprintf("Languages: %s", languages)
	})

	http.ListenAndServe(":8090", m)
}

Authors

# Functions

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

# Structs

A single language from the Accept-Language HTTP header.

# Type aliases

A slice of sortable AcceptLanguage instances.