Documentation ¶
Index ¶
- Constants
- Variables
- func PreferredCharsets(accept string, provided ...string) []string
- func PreferredEncodings(accept string, provided ...string) []string
- func PreferredLanguages(accept string, provided ...string) []string
- func PreferredMediaTypes(accept string, provided ...string) []string
- type Negotiator
- func (n *Negotiator) Charset(available ...string) string
- func (n *Negotiator) Charsets(available ...string) []string
- func (n *Negotiator) Encoding(available ...string) string
- func (n *Negotiator) Encodings(available ...string) []string
- func (n *Negotiator) Language(available ...string) string
- func (n *Negotiator) Languages(available ...string) []string
- func (n *Negotiator) MediaType(available ...string) string
- func (n *Negotiator) MediaTypes(available ...string) []string
Constants ¶
const Version = "v0.6.3"
Version is the current version of negotiator.
Variables ¶
var HeaderAccept = textproto.CanonicalMIMEHeaderKey("Accept")
HeaderAccept is `Accept`
var HeaderAcceptCharset = textproto.CanonicalMIMEHeaderKey("Accept-Charset")
HeaderAcceptCharset is `Accept-Charset`
var HeaderAcceptEncoding = textproto.CanonicalMIMEHeaderKey("Accept-Encoding")
HeaderAcceptEncoding is `Accept-Encoding`
var HeaderAcceptLanguage = textproto.CanonicalMIMEHeaderKey("Accept-Language")
HeaderAcceptLanguage is `Accept-Language`
Functions ¶
func PreferredCharsets ¶
PreferredCharsets gets the preferred charsets from an Accept-Charset header. RFC 2616 sec 14.2: no header = *, so you should pass * if no Accept-Charset field in header.
func PreferredEncodings ¶
PreferredEncodings gets the preferred encodings from an Accept-Encoding header.
func PreferredLanguages ¶
PreferredLanguages gets the preferred languages from an Accept-Language header. RFC 2616 sec 14.2: no header = *, so you should pass * if no Accept-Language field in header.
Types ¶
type Negotiator ¶
Negotiator gets the negotiation info from http header
func New ¶
func New(header http.Header) *Negotiator
New creates a Negotiator instance from a header object.
func (*Negotiator) Charset ¶
func (n *Negotiator) Charset(available ...string) string
Charset gets the most preferred charset from a list of available charsets.
func (*Negotiator) Charsets ¶
func (n *Negotiator) Charsets(available ...string) []string
Charsets gets an array of preferred charsets ordered by priority from a list of available charsets.
func (*Negotiator) Encoding ¶
func (n *Negotiator) Encoding(available ...string) string
Encoding gets the most preferred encoding from a list of available encodings.
func (*Negotiator) Encodings ¶
func (n *Negotiator) Encodings(available ...string) []string
Encodings gets an array of preferred encodings ordered by priority from a list of available encodings.
func (*Negotiator) Language ¶
func (n *Negotiator) Language(available ...string) string
Language gets the most preferred language from a list of available languages.
func (*Negotiator) Languages ¶
func (n *Negotiator) Languages(available ...string) []string
Languages gets an array of preferred languages ordered by priority from a list of available languages.
func (*Negotiator) MediaType ¶
func (n *Negotiator) MediaType(available ...string) string
MediaType gets the most preferred media type from a list of available media types.
func (*Negotiator) MediaTypes ¶
func (n *Negotiator) MediaTypes(available ...string) []string
MediaTypes gets an array of preferred mediaTypes ordered by priority from a list of available media types.