Documentation ¶
Index ¶
- Variables
- type LangMiddleware
- func NewCookieAndHeader(defaultLang string, supportedLanguages []string, cookieName string) (*LangMiddleware, error)
- func NewCookieOnly(defaultLang string, supportedLanguages []string, cookieName string) (*LangMiddleware, error)
- func NewHeaderOnly(defaultLang string, supportedLanguages []string) (*LangMiddleware, error)
- type LangSource
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrHeaderParsing is returned by ParseLangHeader when accept language header is not conform ErrHeaderParsing = errors.New("An error occurred while parsing accept-language header") // ErrEmptyHeader is returned by ParseLangHeader when no tags are provided in header ErrEmptyHeader = errors.New("Accept-language header is empty") )
View Source
var LangContextKey = &contextKey{"lang"}
LangContextKey is the key used to store Lang in context
Functions ¶
This section is empty.
Types ¶
type LangMiddleware ¶
type LangMiddleware struct { CookieName string SupportedLanguages []string DefaultLanguage string // contains filtered or unexported fields }
LangMiddleware
func NewCookieAndHeader ¶
func NewCookieAndHeader(defaultLang string, supportedLanguages []string, cookieName string) (*LangMiddleware, error)
NewCookieAndHeader returns a new LangMiddleware with a configuration to use informations from both cookie and accept-language header
func NewCookieOnly ¶
func NewCookieOnly(defaultLang string, supportedLanguages []string, cookieName string) (*LangMiddleware, error)
NewCookieOnly returns a new LangMiddleware with a configuration to use only informations from cookie named
func NewHeaderOnly ¶
func NewHeaderOnly(defaultLang string, supportedLanguages []string) (*LangMiddleware, error)
NewHeaderOnly returns a new LangMiddleware with a configuration to use only informations from accept-language header
type LangSource ¶
type LangSource int
LangSource can be used to select possible source of language
const ( // Cookie indicates that only cookie will be used to extract language informations Cookie LangSource = 1 << iota // Header indicates that only header will be used to extract language informations Header // HeaderAndCookie indicates that both header and cookie will be used to extract language informations HeaderAndCookie = Cookie | Header )
Click to show internal directories.
Click to hide internal directories.