Documentation ¶
Overview ¶
Package config defines the default settings and semantic variables
Index ¶
- Constants
- Variables
- type Amber
- type BasicAuth
- type CompilerOptions
- type Editor
- type EngineType
- type HTMLTemplate
- type Iris
- type IrisControl
- type Jade
- type Logger
- type Mail
- type Markdown
- type Pongo
- type Redis
- type Render
- type Rest
- type Server
- type Sessions
- type Template
- type Tsconfig
- type Typescript
- type Websocket
Constants ¶
const ( // DefaultBasicAuthRealm is "Authorization Required" DefaultBasicAuthRealm = "Authorization Required" // DefaultBasicAuthContextKey is the "auth" // this key is used to do context.Set("auth", theUsernameFromBasicAuth) DefaultBasicAuthContextKey = "auth" )
const ( DefaultDisablePathCorrection = false DefaultDisablePathEscape = false )
Default values for base Iris conf
const ( // DefaultServerHostname returns the default hostname which is 127.0.0.1 DefaultServerHostname = "127.0.0.1" // DefaultServerPort returns the default port which is 8080 DefaultServerPort = 8080 )
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 // DefaultRedisNetwork the redis network option, "tcp" DefaultRedisNetwork = "tcp" // DefaultRedisAddr the redis address option, "127.0.0.1:6379" DefaultRedisAddr = "127.0.0.1:6379" // DefaultRedisIdleTimeout the redis idle timeout option, time.Duration(5) * time.Minute DefaultRedisIdleTimeout = time.Duration(5) * time.Minute // DefaultRedisMaxAgeSeconds the redis storage last parameter (SETEX), 31556926.0 (1 year) DefaultRedisMaxAgeSeconds = 31556926.0 //1 year )
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 )
Currently only these 5 values are used for real
const DefaultLoggerPrefix = ""
DefaultLoggerPrefix is the prefix (expect the [IRIS]), is empty for now
const ServerName = "iris"
ServerName the response header of the 'Server' value when writes to the client
Variables ¶
var ( // 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 ( // DefaultUsername used for default (basic auth) username in IrisControl's & Editor's default configuration DefaultUsername = "iris" // DefaultPassword used for default (basic auth) password in IrisControl's & Editor's default configuration DefaultPassword = "admin!123" )
var (
// Charset character encoding.
Charset = "UTF-8"
)
var (
// CookieExpireNever the default cookie's life for sessions, unlimited
CookieExpireNever = universe
)
var ( // DefaultServerAddr the default server addr which is: 127.0.0.1:8080 DefaultServerAddr = DefaultServerHostname + ":" + strconv.Itoa(DefaultServerPort) )
var (
// TimeFormat default time format for any kind of datetime parsing
TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
)
Functions ¶
This section is empty.
Types ¶
type Amber ¶
type Amber struct { // Funcs for the html/template result, amber default funcs are not overrided so use it without worries Funcs template.FuncMap }
Amber the configs for AmberEngine
type BasicAuth ¶
type BasicAuth struct { // Users a map of login and the value (username/password) Users map[string]string // Realm http://tools.ietf.org/html/rfc2617#section-1.2. Default is "Authorization Required" Realm string // ContextKey the key for ctx.GetString(...). Default is 'auth' ContextKey string // Expires expiration duration, default is 0 never expires Expires time.Duration }
BasicAuth the configs for the basicauth middleware
func DefaultBasicAuth ¶
func DefaultBasicAuth() BasicAuth
DefaultBasicAuth returns the default configs for the BasicAuth middleware
func (BasicAuth) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type CompilerOptions ¶
type CompilerOptions struct { Declaration bool `json:"declaration"` Module string `json:"module"` Target string `json:"target"` Watch bool `json:"watch"` Charset string `json:"charset"` Diagnostics bool `json:"diagnostics"` EmitBOM bool `json:"emitBOM"` EmitDecoratorMetadata bool `json:"emitDecoratorMetadata"` ExperimentalDecorators bool `json:"experimentalDecorators"` InlineSourceMap bool `json:"inlineSourceMap"` InlineSources bool `json:"inlineSources"` IsolatedModules bool `json:"isolatedModules"` Jsx string `json:"jsx"` ReactNamespace string `json:"reactNamespace"` ListFiles bool `json:"listFiles"` Locale string `json:"locale"` MapRoot string `json:"mapRoot"` ModuleResolution string `json:"moduleResolution"` NewLine string `json:"newLine"` NoEmit bool `json:"noEmit"` NoEmitOnError bool `json:"noEmitOnError"` NoEmitHelpers bool `json:"noEmitHelpers"` NoImplicitAny bool `json:"noImplicitAny"` NoLib bool `json:"noLib"` NoResolve bool `json:"noResolve"` SkipDefaultLibCheck bool `json:"skipDefaultLibCheck"` OutDir string `json:"outDir"` OutFile string `json:"outFile"` PreserveConstEnums bool `json:"preserveConstEnums"` Pretty bool `json:"pretty"` RemoveComments bool `json:"removeComments"` RootDir string `json:"rootDir"` SourceMap bool `json:"sourceMap"` SourceRoot string `json:"sourceRoot"` StripInternal bool `json:"stripInternal"` SuppressExcessPropertyErrors bool `json:"suppressExcessPropertyErrors"` SuppressImplicitAnyIndexErrors bool `json:"suppressImplicitAnyIndexErrors"` AllowUnusedLabels bool `json:"allowUnusedLabels"` NoImplicitReturns bool `json:"noImplicitReturns"` NoFallthroughCasesInSwitch bool `json:"noFallthroughCasesInSwitch"` AllowUnreachableCode bool `json:"allowUnreachableCode"` ForceConsistentCasingInFileNames bool `json:"forceConsistentCasingInFileNames"` AllowSyntheticDefaultImports bool `json:"allowSyntheticDefaultImports"` AllowJs bool `json:"allowJs"` NoImplicitUseStrict bool `json:"noImplicitUseStrict"` }
CompilerOptions contains all the compiler options used by the tsc (typescript compiler)
type Editor ¶
type Editor struct { // Host if empty used the iris server's host Host string // Port if 0 4444 Port int // WorkingDir if empty "./" WorkingDir string // Username if empty iris Username string // Password if empty admin!123 Password string }
Editor the configs for the Editor plugin
func DefaultEditor ¶
func DefaultEditor() Editor
DefaultEditor returns the default configs for the Editor plugin
func (Editor) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type EngineType ¶
type EngineType int8
EngineType is the type of template engine
const ( // NoEngine is a Template's config for engine type // when use this, the templates are disabled NoEngine EngineType = -1 // HTMLEngine is a Template's config for engine type // when use this, the templates are html/template HTMLEngine EngineType = 0 // PongoEngine is a Template's config for engine type // when use this, the templates are flosch/pongo2 PongoEngine EngineType = 1 // MarkdownEngine is a Template's config for engine type // when use this, the templates are .md files MarkdownEngine EngineType = 2 // JadeEngine is a Template's config for engine type // when use this, the templates are joker/jade JadeEngine EngineType = 3 // AmberEngine is a Template's config for engine type // when use this, the templates are eknkc/amber AmberEngine EngineType = 4 // DefaultEngine is the HTMLEngine DefaultEngine EngineType = HTMLEngine // NoLayout to disable layout for a particular template file NoLayout = "@.|.@iris_no_layout@.|.@" // TemplateLayoutContextKey is the name of the user values which can be used to set a template layout from a middleware and override the parent's TemplateLayoutContextKey = "templateLayout" )
type HTMLTemplate ¶
type HTMLTemplate struct { // RequirePartials default is false RequirePartials bool // Delims // Left delimeter, default is {{ Left string // Right delimeter, default is }} Right string // Funcs like html/template Funcs map[string]interface{} // LayoutFuncs like html/template // the difference from Funcs is that these funcs // can be used inside a layout and can override the predefined (yield,partial...) or add more custom funcs // these can override the Funcs inside no-layout templates also, use it when you know what you're doing LayoutFuncs map[string]interface{} }
HTMLTemplate the configs for HTMLEngine
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 // MaxRequestBodySize Maximum request body size. // // The server rejects requests with bodies exceeding this limit. // // By default request body size is -1, unlimited. MaxRequestBodySize int64 // 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 // Logger the configuration for the logger // Iris logs ONLY SEMANTIC errors and the banner if enabled Logger Logger // Sessions contains the configs for sessions Sessions Sessions // Render contains the configs for template and rest configuration Render Render // Websocket contains the configs for Websocket's server integration Websocket *Websocket // Mail contains the configs for the mail sender service Mail Mail // Server contains the configs for the http server // Server configs are the only one which are setted inside base Iris package (from Listen, ListenTLS, ListenUNIX) NO from users // // this field is useful only when you need to READ which is the server's address, certfile & keyfile or unix's mode. // Server Server }
Iris configs for the station All fields can be changed before server's listen except the DisablePathCorrection field
MaxRequestBodySize is the only options that can be changed after server listen - using Config.MaxRequestBodySize = ... Render's rest config can be changed after declaration but before server's listen - using Config.Render.Rest... Render's Template config can be changed after declaration but before server's listen - using Config.Render.Template... Sessions config can be changed after declaration but before server's listen - using Config.Sessions... and so on...
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 IrisControl ¶
type IrisControl struct { // Port the port Port int // Users the authenticated users, [username]password Users map[string]string }
IrisControl the options which iris control needs contains the port (int) and authenticated users with their passwords (map[string]string)
func DefaultIrisControl ¶
func DefaultIrisControl() IrisControl
DefaultIrisControl returns the default configs for IrisControl plugin
func (IrisControl) Merge ¶
func (c IrisControl) Merge(cfg []IrisControl) (config IrisControl)
Merge merges the default with the given config and returns the result
type Logger ¶
type Logger struct { // Out the (file) writer which the messages/logs will printed to // Default is os.Stdout Out *os.File // Prefix the prefix for each message // Default is "" Prefix string // Disabled default is false Disabled bool // ColorFgDefault the foreground color for the normal message bodies ColorFgDefault int // ColorFgInfo the foreground color for info messages ColorFgInfo int // ColorFgSuccess the foreground color for success messages ColorFgSuccess int // ColorFgWarning the foreground color for warning messages ColorFgWarning int // ColorFgDanger the foreground color for error messages ColorFgDanger int // OtherFgColor the foreground color for the rest of the message types ColorFgOther int // ColorBgDefault the background color for the normal messages ColorBgDefault int // ColorBgInfo the background color for info messages ColorBgInfo int // ColorBgSuccess the background color for success messages ColorBgSuccess int // ColorBgWarning the background color for warning messages ColorBgWarning int // ColorBgDanger the background color for error messages ColorBgDanger int // OtherFgColor the background color for the rest of the message types ColorBgOther int // ColorFgBanner the foreground color for the banner ColorFgBanner int }
Logger contains the full configuration options fields for the Logger
func DefaultLogger ¶
func DefaultLogger() Logger
DefaultLogger returns the default configs for the Logger
func (Logger) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type Mail ¶
type Mail struct { // Host is the server mail host, IP or address Host string // Port is the listening port Port int // Username is the auth username@domain.com for the sender Username string // Password is the auth password for the sender Password string // FromAlias is the from part, if empty this is the first part before @ from the Username field FromAlias string // UseCommand enable it if you want to send e-mail with the mail command instead of smtp // // Host,Port & Password will be ignored // ONLY FOR UNIX UseCommand bool }
Mail keeps the configs for mail sender service
func DefaultMail ¶
func DefaultMail() Mail
DefaultMail returns the default configs for Mail returns just an empty Mail struct
type Markdown ¶
type Markdown struct {
Sanitize bool // if true then returns safe html, default is false
}
Markdown the configs for MarkdownEngine
type Pongo ¶
type Pongo struct { // Filters for pongo2, map[name of the filter] the filter function . The filters are auto register Filters map[string]pongo2.FilterFunction // Globals share context fields between templates. https://github.com/flosch/pongo2/issues/35 Globals map[string]interface{} }
Pongo the configs for PongoEngine
type Redis ¶
type Redis struct { // Network "tcp" Network string // Addr "127.0.01:6379" Addr string // Password string .If no password then no 'AUTH'. Default "" Password string // If Database is empty "" then no 'SELECT'. Default "" Database string // MaxIdle 0 no limit MaxIdle int // MaxActive 0 no limit MaxActive int // IdleTimeout time.Duration(5) * time.Minute IdleTimeout time.Duration // Prefix "myprefix-for-this-website". Default "" Prefix string // MaxAgeSeconds how much long the redis should keep the session in seconds. Default 31556926.0 (1 year) MaxAgeSeconds int }
Redis the redis configuration used inside sessions
func DefaultRedis ¶
func DefaultRedis() Redis
DefaultRedis returns the default configuration for Redis service
func (Redis) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type Render ¶
type Render struct { // Template the configs for template Template Template // Rest configs for rendering. // // these options inside this config don't have any relation with the TemplateEngine // from github.com/kataras/iris/rest Rest Rest }
Render struct keeps organise all configuration about rendering, templates and rest currently.
func DefaultRender ¶
func DefaultRender() Render
DefaultRender returns default configuration for templates and rest rendering
type Rest ¶
type Rest struct { // Appends the given character set to the Content-Type header. Default is "UTF-8". Charset string // Gzip enable it if you want to render with gzip compression. Default is false Gzip bool // Outputs human readable JSON. IndentJSON bool // Outputs human readable XML. Default is false. IndentXML bool // Prefixes the JSON output with the given bytes. Default is false. PrefixJSON []byte // Prefixes the XML output with the given bytes. PrefixXML []byte // Unescape HTML characters "&<>" to their original values. Default is false. UnEscapeHTML bool // Streams JSON responses instead of marshalling prior to sending. Default is false. StreamingJSON bool // Disables automatic rendering of http.StatusInternalServerError when an error occurs. Default is false. DisableHTTPErrorRendering bool // MarkdownSanitize sanitizes the markdown. Default is false. MarkdownSanitize bool }
Rest is a struct for specifying configuration options for the rest.Render object.
func (Rest) 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 // Mode this is for unix only Mode os.FileMode }
Server used inside server for listening
func DefaultServer ¶
func DefaultServer() Server
DefaultServer returns the default configs for the server
type Sessions ¶
type Sessions struct { // Provider string, usage iris.Config().Provider = "memory" or "redis". If you wan to customize redis then import the package, and change it's config Provider string // Cookie string, the session's client cookie name, for example: "irissessionid" Cookie string //Expires the date which the cookie must expires. Default infinitive/unlimited life Expires time.Time // 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 memory until the user comes back, then the session continue to work as it was // // Default 2 hours GcDuration time.Duration }
Sessions the configuration for sessions has 4 fields first is the providerName (string) ["memory","redis"] second is the cookieName, the session's name (string) ["mysessionsecretcookieid"] 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
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 Template ¶
type Template struct { // Engine the type of template engine // default is DefaultEngine (HTMLEngine) Engine EngineType // Gzip enable gzip compression // default is false Gzip bool // IsDevelopment re-builds the templates on each request // default is false IsDevelopment bool // Directory the system path which the templates live // default is ./templates Directory string // Extensions the allowed file extension // default is []string{".html"} Extensions []string // ContentType is the Content-Type response header // default is text/html but you can change if if needed ContentType string // Charset the charset, default is UTF-8 Charset string // Asset is a func which returns bytes, use it to load the templates by binary Asset func(name string) ([]byte, error) // AssetNames should returns the template filenames, look Asset AssetNames func() []string // Layout the template file ( with its extension) which is the mother of all // use it to have it as a root file, and include others with {{ yield }}, refer the docs Layout string // HTMLTemplate contains specific configs for HTMLTemplate standard html/template HTMLTemplate HTMLTemplate // Jade contains specific configs for Jade Jade Jade // Pongo contains specific configs for pongo2 Pongo Pongo // Markdown contains specific configs for markdown // this doesn't supports Layout & binding context Markdown Markdown // Amber contains specific configs for amber Amber Amber }
Template the configs for templates (template/view engines) contains common configs for all template engines
func DefaultTemplate ¶
func DefaultTemplate() Template
DefaultTemplate returns the default template configs
func (Template) MergeSingle ¶
MergeSingle merges the default with the given config and returns the result
type Tsconfig ¶
type Tsconfig struct { CompilerOptions CompilerOptions `json:"compilerOptions"` Exclude []string `json:"exclude"` }
Tsconfig the struct for tsconfig.json
func DefaultTsconfig ¶
func DefaultTsconfig() Tsconfig
DefaultTsconfig returns the default Tsconfig, with CompilerOptions module: commonjs, target: es5 and ignore the node_modules
func (Tsconfig) CompilerArgs ¶
CompilerArgs returns the CompilerOptions' contents of the Tsconfig it reads the json tags, add '--' at the start of each one and returns an array of strings
type Typescript ¶
type Typescript struct { // Bin the path of the tsc binary file // if empty then the plugin tries to find it Bin string // Dir the client side directory, which typescript (.ts) files are live Dir string // Ignore ignore folders, default is /node_modules/ Ignore string // Tsconfig the typescript build configs, including the compiler's options Tsconfig Tsconfig // Editor the Editor plugin Editor Editor }
Typescript the configs for the Typescript plugin
func DefaultTypescript ¶
func DefaultTypescript() Typescript
DefaultTypescript returns the default Options of the Typescript plugin Bin and Editor are setting in runtime via the plugin
func (Typescript) Merge ¶
func (c Typescript) Merge(cfg []Typescript) (config Typescript)
Merge merges the default with the given config and returns the result
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 'websocket' package
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