// 1. user/dev have no worries what option to pass, he/she can just press iris.Option and all options should be shown to her/his editor's autocomplete-popup window
// 2. can be passed with any order
// 3. Can override previous configuration
OptionSetterinterface{
// Set receives a pointer to the global Configuration type and does the job of filling it
Set(c*Configuration)
}
// OptionSet implements the OptionSetter
OptionSetfunc(c*Configuration)
)
// Set is the func which makes the OptionSet an OptionSetter, this is used mostly
func(oOptionSet)Set(c*Configuration){
o(c)
}
// Configuration the whole configuration for an iris instance ($instance.Config) or global iris instance (iris.Config)
// these can be passed via options also, look at the top of this file(configuration.go)
//
// Configuration is also implements the OptionSet so it's a valid option itself, this is briliant enough
typeConfigurationstruct{
// 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
DisablePathCorrectionbool
// 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
// 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
ProfilePathstring
// DisableTemplateEngines set to true to disable loading the default template engine (html/template) and disallow the use of iris.UseEngine
// default is false
DisableTemplateEnginesbool
// IsDevelopment iris will act like a developer, for example
// If true then re-builds the templates on each request
// default is false
IsDevelopmentbool
// TimeFormat time format for any kind of datetime parsing
TimeFormatstring
// Charset character encoding for various rendering
// used for templates and the rest of the responses
// defaults to "UTF-8"
Charsetstring
// 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
Gzipbool
// Sessions contains the configs for sessions
SessionsSessionsConfiguration
// Websocket contains the configs for Websocket's server integration
WebsocketWebsocketConfiguration
// 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
TesterTesterConfiguration
// Other are the custom, dynamic options, can be empty
// this fill used only by you to set any app's options you want
// for each of an Iris instance
Otheroptions.Options
}
// Set implements the OptionSetter
func(cConfiguration)Set(main*Configuration){
mergo.MergeWithOverwrite(main,c)
}
// All options starts with "Option" preffix in order to be easier to find what dev searching for
var(
// OptionDisablePathCorrection 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
// OptionIsDevelopment iris will act like a developer, for example
// If true then re-builds the templates on each request
// Default is false
OptionIsDevelopment=func(valbool)OptionSet{
returnfunc(c*Configuration){
c.IsDevelopment=val
}
}
// OptionTimeFormat time format for any kind of datetime parsing
OptionTimeFormat=func(valstring)OptionSet{
returnfunc(c*Configuration){
c.TimeFormat=val
}
}
// OptionCharset character encoding for various rendering
// used for templates and the rest of the responses
// Default is "UTF-8"
OptionCharset=func(valstring)OptionSet{
returnfunc(c*Configuration){
c.Charset=val
}
}
// OptionGzip 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})
// Default is false
OptionGzip=func(valbool)OptionSet{
returnfunc(c*Configuration){
c.Gzip=val
}
}
// OptionOther are the custom, dynamic options, can be empty
// this fill used only by you to set any app's options you want
// for each of an Iris instance
OptionOther=func(val...options.Options)OptionSet{
opts:=options.Options{}
for_,opt:=rangeval{
fork,v:=rangeopt{
opts[k]=v
}
}
returnfunc(c*Configuration){
c.Other=opts
}
}
)
var(
// DefaultTimeFormat default time format for any kind of datetime parsing
DefaultTimeFormat="Mon, 02 Jan 2006 15:04:05 GMT"
// StaticCacheDuration expiration duration for INACTIVE file handlers, it's a global configuration field to all iris instances
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"
)
// Default values for base Iris conf
const(
DefaultDisablePathCorrection=false
DefaultDisablePathEscape=false
DefaultCharset="UTF-8"
DefaultLoggerPreffix="[IRIS] "
)
var(
// DefaultLoggerOut is the default logger's output
DefaultLoggerOut=os.Stdout
)
// DefaultConfiguration returns the default configuration for an Iris station, fills the main Configuration
// The server rejects requests with bodies exceeding this limit.
//
// By default request body size is 8MB.
MaxRequestBodySizeint
// 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.
ReadBufferSizeint
// Per-connection buffer size for responses' writing.
//
// Default buffer size is used if not set.
WriteBufferSizeint
// Maximum duration for reading the full request (including body).
//
// This also limits the maximum duration for idle keep-alive
// connections.
//
// By default request read timeout is unlimited.
ReadTimeouttime.Duration
// Maximum duration for writing the full response (including body).
//
// By default response write timeout is unlimited.
WriteTimeouttime.Duration
// 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.
// 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.