Documentation
¶
Index ¶
- Variables
- func Handler(rc *Config, formsizefile int64, handler http.HandlerFunc) http.HandlerFunc
- type Config
- type UserRequest
- func (ur *UserRequest) Charset() string
- func (ur *UserRequest) Encoding() string
- func (ur *UserRequest) IP() string
- func (ur *UserRequest) IsLocalhost() bool
- func (ur *UserRequest) LangDir() string
- func (ur *UserRequest) Language() string
- func (ur *UserRequest) Media() string
- func (ur *UserRequest) Query() map[string]string
- func (ur *UserRequest) Referrer() *url.URL
- func (ur *UserRequest) Timezone() *time.Location
- func (ur *UserRequest) URL() *url.URL
- func (ur *UserRequest) Useragent() *useragent.Product
Constants ¶
This section is empty.
Variables ¶
var DefaultLang = "en"
DefaultLang is the default language. Need to be setted in the starup of the application.
Functions ¶
func Handler ¶
func Handler(rc *Config, formsizefile int64, handler http.HandlerFunc) http.HandlerFunc
Handler reads the information in the request parameter and process it, the result got to the context under the name "request". All data from the request must be accessed with the function Request(r), i.e. Request(r).Referrer(). This is done with the intent of make the information in r more acessible and in this way avaid repetitive work.
Types ¶
type Config ¶
type Config struct { AcceptedUserAgents *useragent.UAVers AcceptedLanguages []string AcceptedEncoding []string AcceptedMedias []string AcceptedCharsets []string Localhosts []string }
Config is the configuration for the request parse and pre processing.
var DefaultConfig *Config
DefaultRequestConfig is a simple default config for request.
type UserRequest ¶
type UserRequest struct {
// contains filtered or unexported fields
}
UserRequest provide methods to access the user request information.
func Request ¶
func Request(r *http.Request) *UserRequest
Request get the user request from the context.
func (*UserRequest) Charset ¶
func (ur *UserRequest) Charset() string
Charset return the accepted charset by the user.
func (*UserRequest) Encoding ¶
func (ur *UserRequest) Encoding() string
Encoding return the encoding algorithm accepted by the user.
func (*UserRequest) IsLocalhost ¶
func (ur *UserRequest) IsLocalhost() bool
IsLocalhost is local host.
func (*UserRequest) LangDir ¶
func (ur *UserRequest) LangDir() string
LangDir is the language write direction, always return ltr.
func (*UserRequest) Language ¶
func (ur *UserRequest) Language() string
Language return the language accepted by the user.
func (*UserRequest) Media ¶
func (ur *UserRequest) Media() string
Media return the accepted media by the user.
func (*UserRequest) Query ¶
func (ur *UserRequest) Query() map[string]string
Query returns a map with the queries in the url made by the user.
func (*UserRequest) Referrer ¶
func (ur *UserRequest) Referrer() *url.URL
Referrer return the referrer url.
func (*UserRequest) Timezone ¶
func (ur *UserRequest) Timezone() *time.Location
Timezone receives the time zone from que query parameter tz in the javascript format and convert it to time.Location.
func (*UserRequest) Useragent ¶
func (ur *UserRequest) Useragent() *useragent.Product
Useragent return the user ua.