Documentation ¶
Overview ¶
Package config defines the default settings and semantic variables
Index ¶
Constants ¶
const ( DefaultDisablePathCorrection = false DefaultDisablePathEscape = false DefaultCharset = "UTF-8" )
Default values for base Iris conf
const ( // DefaultServerHostname returns the default hostname which is 0.0.0.0 DefaultServerHostname = "0.0.0.0" // DefaultServerPort returns the default port which is 8080 DefaultServerPort = 8080 // DefaultMaxRequestBodySize is 8MB DefaultMaxRequestBodySize = 2 * fasthttp.DefaultMaxRequestBodySize // Per-connection buffer size for requests' reading. // This also limits the maximum header size. // // Increase this buffer if your clients send multi-KB RequestURIs // and/or multi-KB headers (for example, BIG cookies). // // Default buffer size is 8MB DefaultReadBufferSize = 8096 // Per-connection buffer size for responses' writing. // // Default buffer size is 8MB DefaultWriteBufferSize = 8096 // DefaultServerName the response header of the 'Server' value when writes to the client DefaultServerName = "iris" )
Default values for base Server conf
const ( // DefaultCookieName the secret cookie's name for sessions DefaultCookieName = "irissessionid" // DefaultSessionGcDuration is the default Session Manager's GCDuration , which is 2 hours DefaultSessionGcDuration = time.Duration(2) * time.Hour )
const ( // DefaultWriteTimeout 15 * time.Second DefaultWriteTimeout = 15 * time.Second // DefaultPongTimeout 60 * time.Second DefaultPongTimeout = 60 * time.Second // DefaultPingPeriod (DefaultPongTimeout * 9) / 10 DefaultPingPeriod = (DefaultPongTimeout * 9) / 10 // DefaultMaxMessageSize 1024 DefaultMaxMessageSize = 1024 )
Variables ¶
var ( // TimeFormat default time format for any kind of datetime parsing TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT" // StaticCacheDuration expiration duration for INACTIVE file handlers StaticCacheDuration = 20 * time.Second // CompressedFileSuffix is the suffix to add to the name of // cached compressed file when using the .StaticFS function. // // Defaults to iris-fasthttp.gz CompressedFileSuffix = "iris-fasthttp.gz" )
var ( // CookieExpireNever the default cookie's life for sessions, unlimited (23 years) CookieExpireNever = time.Now().AddDate(23, 0, 0) )
var ( // DefaultServerAddr the default server addr which is: 0.0.0.0:8080 DefaultServerAddr = DefaultServerHostname + ":" + strconv.Itoa(DefaultServerPort) )
Functions ¶
func ServerParseAddr ¶
ServerParseAddr parses the listening addr and returns this
Types ¶
type Iris ¶
type Iris struct { // DisablePathCorrection corrects and redirects the requested path to the registed path // for example, if /home/ path is requested but no handler for this Route found, // then the Router checks if /home handler exists, if yes, // (permant)redirects the client to the correct path /home // // Default is false DisablePathCorrection bool // DisablePathEscape when is false then its escapes the path, the named parameters (if any). // Change to true it if you want something like this https://github.com/kataras/iris/issues/135 to work // // When do you need to Disable(true) it: // accepts parameters with slash '/' // Request: http://localhost:8080/details/Project%2FDelta // ctx.Param("project") returns the raw named parameter: Project%2FDelta // which you can escape it manually with net/url: // projectName, _ := url.QueryUnescape(c.Param("project"). // Look here: https://github.com/kataras/iris/issues/135 for more // // Default is false DisablePathEscape bool // DisableBanner outputs the iris banner at startup // // Default is false DisableBanner bool // ProfilePath a the route path, set it to enable http pprof tool // Default is empty, if you set it to a $path, these routes will handled: // $path/cmdline // $path/profile // $path/symbol // $path/goroutine // $path/heap // $path/threadcreate // $path/pprof/block // for example if '/debug/pprof' // http://yourdomain:PORT/debug/pprof/ // http://yourdomain:PORT/debug/pprof/cmdline // http://yourdomain:PORT/debug/pprof/profile // http://yourdomain:PORT/debug/pprof/symbol // http://yourdomain:PORT/debug/pprof/goroutine // http://yourdomain:PORT/debug/pprof/heap // http://yourdomain:PORT/debug/pprof/threadcreate // http://yourdomain:PORT/debug/pprof/pprof/block // it can be a subdomain also, for example, if 'debug.' // http://debug.yourdomain:PORT/ // http://debug.yourdomain:PORT/cmdline // http://debug.yourdomain:PORT/profile // http://debug.yourdomain:PORT/symbol // http://debug.yourdomain:PORT/goroutine // http://debug.yourdomain:PORT/heap // http://debug.yourdomain:PORT/threadcreate // http://debug.yourdomain:PORT/pprof/block ProfilePath string // DisableTemplateEngines set to true to disable loading the default template engine (html/template) and disallow the use of iris.UseEngine // default is false DisableTemplateEngines bool // IsDevelopment iris will act like a developer, for example // If true then re-builds the templates on each request // default is false IsDevelopment bool // Charset character encoding for various rendering // used for templates and the rest of the responses // defaults to "UTF-8" Charset string // Gzip enables gzip compression on your Render actions, this includes any type of render, templates and pure/raw content // If you don't want to enable it globaly, you could just use the third parameter on context.Render("myfileOrResponse", structBinding{}, iris.RenderOptions{"gzip": true}) // defaults to false Gzip bool // Sessions contains the configs for sessions Sessions Sessions // Websocket contains the configs for Websocket's server integration Websocket *Websocket // Tester contains the configs for the test framework, so far we have only one because all test framework's configs are setted by the iris itself // You can find example on the https://github.com/kataras/iris/glob/master/context_test.go Tester Tester }
Iris configs for the station
func (Iris) Merge ¶
Merge merges the default with the given config and returns the result receives an array because the func caller is variadic
func (Iris) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type Server ¶
type Server struct { // ListenningAddr the addr that server listens to ListeningAddr string CertFile string KeyFile string // AutoTLS enable to get certifications from the Letsencrypt // when this configuration field is true, the CertFile & KeyFile are empty, no need to provide a key. // // example: https://github.com/iris-contrib/examples/blob/master/letsencyrpt/main.go AutoTLS bool // Mode this is for unix only Mode os.FileMode // MaxRequestBodySize Maximum request body size. // // The server rejects requests with bodies exceeding this limit. // // By default request body size is 8MB. MaxRequestBodySize int // Per-connection buffer size for requests' reading. // This also limits the maximum header size. // // Increase this buffer if your clients send multi-KB RequestURIs // and/or multi-KB headers (for example, BIG cookies). // // Default buffer size is used if not set. ReadBufferSize int // Per-connection buffer size for responses' writing. // // Default buffer size is used if not set. WriteBufferSize int // RedirectTo, defaults to empty, set it in order to override the station's handler and redirect all requests to this address which is of form(HOST:PORT or :PORT) // // NOTE: the http status is 'StatusMovedPermanently', means one-time-redirect(the browser remembers the new addr and goes to the new address without need to request something from this server // which means that if you want to change this address you have to clear your browser's cache in order this to be able to change to the new addr. // // example: https://github.com/iris-contrib/examples/tree/master/multiserver_listening2 RedirectTo string // Virtual If this server is not really listens to a real host, it mostly used in order to achieve testing without system modifications Virtual bool // VListeningAddr, can be used for both virtual = true or false, // if it's setted to not empty, then the server's Host() will return this addr instead of the ListeningAddr. // server's Host() is used inside global template helper funcs // set it when you are sure you know what it does. // // Default is empty "" VListeningAddr string // VScheme if setted to not empty value then all template's helper funcs prepends that as the url scheme instead of the real scheme // server's .Scheme returns VScheme if not empty && differs from real scheme // // Default is empty "" VScheme string // Name the server's name, defaults to "iris". // You're free to change it, but I will trust you to don't, this is the only setting whose somebody, like me, can see if iris web framework is used Name string }
Server used inside server for listening
func DefaultServer ¶
func DefaultServer() Server
DefaultServer returns the default configs for the server
func (Server) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type Sessions ¶
type Sessions struct { // Cookie string, the session's client cookie name, for example: "irissessionid" Cookie string // DecodeCookie set it to true to decode the cookie key with base64 URLEncoding // Defaults to false DecodeCookie bool Expires time.Duration // GcDuration every how much duration(GcDuration) the memory should be clear for unused cookies (GcDuration) // for example: time.Duration(2)*time.Hour. it will check every 2 hours if cookie hasn't be used for 2 hours, // deletes it from backend memory until the user comes back, then the session continue to work as it was // // Default 2 hours GcDuration time.Duration // DisableSubdomainPersistence set it to true in order dissallow your iris subdomains to have access to the session cookie // defaults to false DisableSubdomainPersistence bool }
Sessions the configuration for sessions has 5 fields first is the cookieName, the session's name (string) ["mysessionsecretcookieid"] second enable if you want to decode the cookie's key also third is the time which the client's cookie expires forth is the gcDuration (time.Duration) when this time passes it removes the unused sessions from the memory until the user come back fifth is the DisableSubdomainPersistence which you can set it to true in order dissallow your iris subdomains to have access to the session cook
func DefaultSessions ¶
func DefaultSessions() Sessions
DefaultSessions the default configs for Sessions
func (Sessions) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type Tester ¶
Tester configuration
func DefaultTester ¶
func DefaultTester() Tester
DefaultTester returns the default configuration for a tester the ListeningAddr is used as virtual only when no running server is founded
type Websocket ¶
type Websocket struct { // WriteTimeout time allowed to write a message to the connection. // Default value is 15 * time.Second WriteTimeout time.Duration // PongTimeout allowed to read the next pong message from the connection // Default value is 60 * time.Second PongTimeout time.Duration // PingPeriod send ping messages to the connection with this period. Must be less than PongTimeout // Default value is (PongTimeout * 9) / 10 PingPeriod time.Duration // MaxMessageSize max message size allowed from connection // Default value is 1024 MaxMessageSize int64 // Endpoint is the path which the websocket server will listen for clients/connections // Default value is empty string, if you don't set it the Websocket server is disabled. Endpoint string // Headers the response headers before upgrader // Default is empty Headers map[string]string // ReadBufferSize is the buffer size for the underline reader ReadBufferSize int // WriteBufferSize is the buffer size for the underline writer WriteBufferSize int }
Websocket the config contains options for the ../websocket.go
func DefaultWebsocket ¶
func DefaultWebsocket() *Websocket
DefaultWebsocket returns the default config for iris-ws websocket package
func (*Websocket) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result