iris package - github.com/kataras/iris/v12 - Go Packages (original) (raw)

Package iris implements the highest realistic performance, easy to learn Go web framework. Iris provides a beautifully expressive and easy to use foundation for your next website, API, or distributed app. Low-level handlers compatible with `net/http` and high-level fastest MVC implementation and handlers dependency injection. Easy to learn for new gophers and advanced features for experienced, it goes as far as you dive into it!

Source code and other details for the project are available at GitHub:

https://github.com/kataras/iris

Current Version

12.2.11

Installation

The only requirement is the Go Programming Language, at least version 1.22.

$ go get github.com/kataras/iris/v12@latest

Wiki:

https://www.iris-go.com/#ebookDonateForm

Examples:

https://github.com/kataras/iris/tree/main/_examples

Middleware:

https://github.com/kataras/iris/tree/main/middleware https://github.com/iris-contrib/middleware

Home Page:

https://iris-go.com

SameSite attributes.

Constants for input argument at `router.RouteRegisterRule`. See `Party#SetRegisterRule`.

Contains the enum values of the `Context.GetReferrer()` method, shortcuts of the context subpackage.

HTTP Methods copied from `net/http`.

HTTP status codes as registered with IANA. See: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml. Raw Copy from the future(tip) net/http std package in order to recude the import path of "net/http" for the users.

Byte unit helpers.

NoLayout to disable layout for a particular template file A shortcut for the `view#NoLayout`.

Version is the current version of the Iris Web Framework.

View Source

var (

StatusText = [context](/github.com/kataras/iris/v12@v12.2.11/context).[StatusText](/github.com/kataras/iris/v12@v12.2.11/context#StatusText)


RegisterMethods = [router](/github.com/kataras/iris/v12@v12.2.11/core/router).[RegisterMethods](/github.com/kataras/iris/v12@v12.2.11/core/router#RegisterMethods)


WebDAVMethods = [][string](/builtin#string){
    [MethodGet](#MethodGet),
    [MethodHead](#MethodHead),
    [MethodPatch](#MethodPatch),
    [MethodPut](#MethodPut),
    [MethodPost](#MethodPost),
    [MethodDelete](#MethodDelete),
    [MethodOptions](#MethodOptions),
    [MethodConnect](#MethodConnect),
    [MethodTrace](#MethodTrace),
    "MKCOL",
    "COPY",
    "MOVE",
    "LOCK",
    "UNLOCK",
    "PROPFIND",
    "PROPPATCH",
    "LINK",
    "UNLINK",
    "PURGE",
    "VIEW",
}

)

View Source

var (

ErrServerClosed = [http](/net/http).[ErrServerClosed](/net/http#ErrServerClosed)


ErrURLQuerySemicolon = [errors](/errors).[New](/errors#New)("http: URL query contains semicolon, which is no longer a supported separator; parts of the query may be stripped when parsed; see golang.org/issue/25192")

)

DefaultTimeoutMessage is the default timeout message which is rendered on expired handlers when timeout handler is registered (see Timeout configuration field).

View Source

var WithDynamicHandler = func(app *Application) { app.config.EnableDynamicHandler = true }

WithDynamicHandler enables for dynamic routing by setting the `EnableDynamicHandler` to true.

See `Configuration`.

WithEasyJSON enables the fast easy json marshaler on Context.JSON method.

See `Configuration` for more.

View Source

var WithEmptyFormError = func(app *Application) { app.config.FireEmptyFormError = true }

WithEmptyFormError enables the setting `FireEmptyFormError`.

See `Configuration`.

View Source

var WithFireMethodNotAllowed = func(app *Application) { app.config.FireMethodNotAllowed = true }

WithFireMethodNotAllowed enables the FireMethodNotAllowed setting.

See `Configuration`.

View Source

var WithGlobalConfiguration = func(app *Application) { app.Configure(WithConfiguration(YAML(globalConfigurationKeyword))) }

WithGlobalConfiguration will load the global yaml configuration file from the home directory and it will set/override the whole app's configuration to that file's contents. The global configuration file can be modified by user and be used by multiple iris instances.

This is useful when we run multiple iris servers that share the same configuration, even with custom values at its "Other" field.

Usage: `app.Configure(iris.WithGlobalConfiguration)` or `app.Run(iris.Runner, iris.WithGlobalConfiguration)`.

View Source

var WithLowercaseRouting = func(app *Application) { app.config.ForceLowercaseRouting = true }

WithLowercaseRouting enables for lowercase routing by setting the `ForceLowercaseRoutes` to true.

See `Configuration`.

View Source

var WithOptimizations = func(app *Application) { app.config.EnableOptimizations = true }

WithOptimizations can force the application to optimize for the best performance where is possible.

See `Configuration`.

View Source

var WithPathEscape = func(app *Application) { app.config.EnablePathEscape = true }

WithPathEscape sets the EnablePathEscape setting to true.

See `Configuration`.

View Source

var WithPathIntelligence = func(app *Application) { app.config.EnablePathIntelligence = true }

WithPathIntelligence enables the EnablePathIntelligence setting.

See `Configuration`.

WithProtoJSON enables the proto marshaler on Context.JSON method.

See `Configuration` for more.

View Source

var WithResetOnFireErrorCode = func(app *Application) { app.config.ResetOnFireErrorCode = true }

WithResetOnFireErrorCode sets the ResetOnFireErrorCode setting to true.

See `Configuration`.

View Source

var WithTunneling = func(app *Application) { conf := TunnelingConfiguration{ Tunnels: []Tunnel{{}}, }

app.config.Tunneling = conf

}

WithTunneling is the `iris.Configurator` for the `iris.Configuration.Tunneling` field. It's used to enable http tunneling for an Iris Application, per registered host

Alternatively use the `iris.WithConfiguration(iris.Configuration{Tunneling: iris.TunnelingConfiguration{ ...}}}`.

View Source

var WithURLParamSeparator = func(sep string) Configurator { return func(app *Application) { app.config.URLParamSeparator = &sep } }

WithURLParamSeparator sets the URLParamSeparator setting to "sep".

See `Configuration`.

View Source

var WithoutAutoFireStatusCode = func(app *Application) { app.config.DisableAutoFireStatusCode = true }

WithoutAutoFireStatusCode sets the DisableAutoFireStatusCode setting to true.

See `Configuration`.

WithoutBanner is a conversion for the `WithoutStartupLog` option.

Turns off the information send, once, to the terminal when the main server is open.

View Source

var WithoutBodyConsumptionOnUnmarshal = func(app *Application) { app.config.DisableBodyConsumptionOnUnmarshal = true }

WithoutBodyConsumptionOnUnmarshal disables BodyConsumptionOnUnmarshal setting.

See `Configuration`.

View Source

var WithoutInterruptHandler = func(app *Application) { app.config.DisableInterruptHandler = true }

WithoutInterruptHandler disables the automatic graceful server shutdown when control/cmd+C pressed.

View Source

var WithoutPathCorrection = func(app *Application) { app.config.DisablePathCorrection = true }

WithoutPathCorrection disables the PathCorrection setting.

See `Configuration`.

View Source

var WithoutPathCorrectionRedirection = func(app *Application) { app.config.DisablePathCorrection = false app.config.DisablePathCorrectionRedirection = true }

WithoutPathCorrectionRedirection disables the PathCorrectionRedirection setting.

See `Configuration`.

View Source

var WithoutStartupLog = func(app *Application) { app.config.DisableStartupLog = true }

WithoutStartupLog turns off the information send, once, to the terminal when the main server is open.

func Compression(ctx Context)

Compression is a middleware which enables writing and reading using the best offered compression. Usage: app.Use (for matched routes) app.UseRouter (for both matched and 404s or other HTTP errors).

ConfigureMiddleware is a PartyConfigurator which can be used as a shortcut to add middlewares on Party.PartyConfigure("/path", WithMiddleware(handler), new(example.API)).

Minify is a middleware which minifies the responses based on the response content type. Note that minification might be slower, caching is advised. Customize the minifier through `Application.Minifier()`. Usage: app.Use(iris.Minify)

PrefixFS same as "PrefixDir" but for `fs.FS` type.

func WithSocketSharding(app *Application)

WithSocketSharding sets the `Configuration.SocketSharding` field to true.

APIContainer is a wrapper of a common `Party` featured by Dependency Injection. See `Party.ConfigureContainer` for more.

A shortcut for the `core/router#APIContainer`.

Application is responsible to manage the state of the application. It contains and handles all the necessary parts to create a fast web server.

func Default() *Application

Default returns a new Application. Default with "debug" Logger Level. Localization enabled on "./locales" directory and HTML templates on "./views" or "./templates" directory. CORS (allow all), Recovery and Request ID middleware already registered.

New creates and returns a fresh empty iris *Application instance.

Build sets up, once, the framework. It builds the default router with its default macros and the template functions that are very-closed to iris.

If error occurred while building the Application, the returns type of error will be an *errgroup.Group which let the callers to inspect the errors and cause, usage:

import "github.com/kataras/iris/v12/core/errgroup"

errgroup.Walk(app.Build(), func(typ interface{}, err error) { app.Logger().Errorf("%s: %s", typ, err) })

ConfigurationReadOnly returns an object which doesn't allow field writing.

func (app *Application) Configure(configurators ...Configurator) *Application

Configure can called when modifications to the framework instance needed. It accepts the framework instance and returns an error which if it's not nil it's printed to the logger. See configuration.go for more.

Returns itself in order to be used like `app:= New().Configure(...)`

ConfigureHost accepts one or more `host#Configuration`, these configurators functions can access the host created by `app.Run` or `app.Listen`, they're being executed when application is ready to being served to the public.

It's an alternative way to interact with a host that is automatically created by `app.Run`.

These "configurators" can work side-by-side with the `iris#Addr, iris#Server, iris#TLS, iris#AutoTLS, iris#Listener` final arguments("hostConfigs") too.

Note that these application's host "configurators" will be shared with the rest of the hosts that this app will may create (using `app.NewHost`), meaning that `app.NewHost` will execute these "configurators" everytime that is being called as well.

These "configurators" should be registered before the `app.Run` or `host.Serve/Listen` functions.

func (*Application) GetContextErrorHandler added in v12.2.0

GetContextErrorHandler returns the handler which handles errors on JSON write failures.

GetContextPool returns the Iris sync.Pool which holds the contexts values. Iris automatically releases the request context, so you don't have to use it. It's only useful to manually release the context on cases that connection is hijacked by a third-party middleware and the http handler return too fast.

I18nReadOnly returns the i18n's read-only features. See `I18n` method for more.

func (app *Application) IsDebug() bool

IsDebug reports whether the application is running under debug/development mode. It's just a shortcut of Logger().Level >= golog.DebugLevel. The same method existss as Context.IsDebug() too.

Listen builds the application and starts the server on the TCP network address "host:port" which handles requests on incoming connections.

Listen always returns a non-nil error except when NonBlocking option is being passed, so the error goes to the Wait method. Ignore specific errors by using an `iris.WithoutServerError(iris.ErrServerClosed)` as a second input argument.

Listen is a shortcut of `app.Run(iris.Addr(hostPort, withOrWithout...))`. See `Run` for details.

Logger returns the golog logger instance(pointer) that is being used inside the "app".

Available levels: - "disable" - "fatal" - "error" - "warn" - "info" - "debug" Usage: app.Logger().SetLevel("error") Or set the level through Configurartion's LogLevel or WithLogLevel functional option. Defaults to "info" level.

Callers can use the application's logger which is the same `golog.Default.LastChild()` logger, to print custom logs too. Usage: app.Logger().Error/Errorf("...") app.Logger().Warn/Warnf("...") app.Logger().Info/Infof("...") app.Logger().Debug/Debugf("...")

Setting one or more outputs: app.Logger().SetOutput(io.Writer...) Adding one or more outputs : app.Logger().AddOutput(io.Writer...)

Adding custom levels requires import of the `github.com/kataras/golog` package:

First we create our level to a golog.Level in order to be used in the Log functions. var SuccessLevel golog.Level = 6 Register our level, just three fields. golog.Levels[SuccessLevel] = &golog.LevelMetadata{ Name: "success", RawText: "[SUCC]", // ColorfulText (Green Color[SUCC]) ColorfulText: "\x1b[32m[SUCC]\x1b[0m", }

Usage: app.Logger().SetLevel("success") app.Logger().Logf(SuccessLevel, "a custom leveled log message")

func (app *Application) Minifier() *minify.M

Minifier returns the minifier instance. By default it can minifies: - text/html - text/css - image/svg+xml - application/text(javascript, ecmascript, json, xml). Use that instance to add custom Minifiers before server ran.

NewHost accepts a standard *http.Server object, completes the necessary missing parts of that "srv" and returns a new, ready-to-use, host (supervisor).

RegisterView registers a view engine for the application. Children can register their own too. If no Party view Engine is registered then this one will be used to render the templates instead.

func (app *Application) Run(serve Runner, withOrWithout ...Configurator) error

Run builds the framework and starts the desired `Runner` with or without configuration edits.

Run should be called only once per Application instance, it blocks like http.Server.

If more than one server needed to run on the same iris instance then create a new host and run it manually by `go NewHost(*http.Server).Serve/ListenAndServe` etc... or use an already created host: h := NewHost(*http.Server) Run(Raw(h.ListenAndServe), WithCharset("utf-8"), WithRemoteAddrHeader("CF-Connecting-IP"))

The Application can go online with any type of server or iris's host with the help of the following runners: `Listener`, `Server`, `Addr`, `TLS`, `AutoTLS` and `Raw`.

func (*Application) SetContextErrorHandler added in v12.2.0

SetContextErrorHandler can optionally register a handler to handle and fire a customized error body to the client on JSON write failures.

ExampleCode:

type contextErrorHandler struct{} func (e *contextErrorHandler) HandleContextError(ctx iris.Context, err error) { errors.HandleError(ctx, err) } ... app.SetContextErrorHandler(new(contextErrorHandler))

SetName sets a unique name to this Iris Application. It sets a child prefix for the current Application's Logger. Look `String` method too.

It returns this Application.

Shutdown gracefully terminates all the application's server hosts and any tunnels. Returns an error on the first failure, otherwise nil.

String completes the fmt.Stringer interface and it returns the application's name. If name was not set by `SetName` or `IRIS_APP_NAME` environment variable then this will return an empty string.

func (*Application) SubdomainRedirect

SubdomainRedirect registers a router wrapper which redirects(StatusMovedPermanently) a (sub)domain to another subdomain or to the root domain as fast as possible, before the router's try to execute route's handler(s).

It receives two arguments, they are the from and to/target locations, 'from' can be a wildcard subdomain as well (app.WildcardSubdomain()) 'to' is not allowed to be a wildcard for obvious reasons, 'from' can be the root domain(app) when the 'to' is not the root domain and visa-versa.

Usage: www := app.Subdomain("www") <- same as app.Party("www.") app.SubdomainRedirect(app, www) This will redirect all http(s)://mydomain.com/%anypath% to http(s)://www.mydomain.com/%anypath%.

One or more subdomain redirects can be used to the same app instance.

If you need more information about this implementation then you have to navigate through the `core/router#NewSubdomainRedirectWrapper` function instead.

Example: https://github.com/kataras/iris/tree/main/_examples/routing/subdomains/redirect

func (app *Application) Validate(v interface{}) error

Validate validates a value and returns nil if passed or the failure reason if does not.

View executes and writes the result of a template file to the writer.

First parameter is the writer to write the parsed template. Second parameter is the relative, to templates directory, template filename, including extension. Third parameter is the layout, can be empty string. Forth parameter is the bindable data to the template, can be nil.

Use context.View to render templates to the client instead. Returns an error on failure, otherwise nil.

WWW creates and returns a "www." subdomain. The difference from `app.Subdomain("www")` or `app.Party("www.")` is that the `app.WWW()` method wraps the router so all http(s)://mydomain.com will be redirect to http(s)://www.mydomain.com. Other subdomains can be registered using the app: `sub := app.Subdomain("mysubdomain")`, child subdomains can be registered using the www := app.WWW(); www.Subdomain("wwwchildSubdomain").

Wait blocks the main goroutine until the server application is up and running. Useful only when `Run` is called with `iris.NonBlocking()` option.

ApplicationBuilder is the final step of the Guide. It is used to register APIs controllers (PartyConfigurators) and its Build, Listen and Run methods configure and build the actual Iris application based on the previous steps.

Attachments options for files to be downloaded and saved locally by the client. See `DirOptions`.

type CompressionGuide interface {

Compression(b [bool](/builtin#bool)) [HealthGuide](#HealthGuide)

}

CompressionGuide is the 2nd step of the Guide. Compression (gzip or any other client requested) can be enabled or disabled.

type Configuration struct {

VHost [string](/builtin#string) `ini:"v_host" json:"vHost" yaml:"VHost" toml:"VHost" env:"V_HOST"`


LogLevel [string](/builtin#string) `ini:"log_level" json:"logLevel" yaml:"LogLevel" toml:"LogLevel" env:"LOG_LEVEL"`


SocketSharding [bool](/builtin#bool) `ini:"socket_sharding" json:"socketSharding" yaml:"SocketSharding" toml:"SocketSharding" env:"SOCKET_SHARDING"`


KeepAlive [time](/time).[Duration](/time#Duration) `ini:"keepalive" json:"keepAlive" yaml:"KeepAlive" toml:"KeepAlive" env:"KEEP_ALIVE"`


Timeout [time](/time).[Duration](/time#Duration) `ini:"timeout" json:"timeout" yaml:"Timeout" toml:"Timeout"`


TimeoutMessage [string](/builtin#string) `ini:"timeout_message" json:"timeoutMessage" yaml:"TimeoutMessage" toml:"TimeoutMessage"`


NonBlocking [bool](/builtin#bool) `ini:"non_blocking" json:"nonBlocking" yaml:"NonBlocking" toml:"NonBlocking"`


Tunneling [TunnelingConfiguration](#TunnelingConfiguration) `ini:"tunneling" json:"tunneling,omitempty" yaml:"Tunneling" toml:"Tunneling"`


IgnoreServerErrors [][string](/builtin#string) `ini:"ignore_server_errors" json:"ignoreServerErrors,omitempty" yaml:"IgnoreServerErrors" toml:"IgnoreServerErrors"`


DisableStartupLog [bool](/builtin#bool) `ini:"disable_startup_log" json:"disableStartupLog,omitempty" yaml:"DisableStartupLog" toml:"DisableStartupLog"`


DisableInterruptHandler [bool](/builtin#bool) `` 


DisablePathCorrection [bool](/builtin#bool) `` 


DisablePathCorrectionRedirection [bool](/builtin#bool) `` 


EnablePathIntelligence [bool](/builtin#bool) `` 


EnablePathEscape [bool](/builtin#bool) `ini:"enable_path_escape" json:"enablePathEscape,omitempty" yaml:"EnablePathEscape" toml:"EnablePathEscape"`


ForceLowercaseRouting [bool](/builtin#bool) `` 


EnableDynamicHandler [bool](/builtin#bool) `ini:"enable_dynamic_handler" json:"enableDynamicHandler,omitempty" yaml:"EnableDynamicHandler" toml:"EnableDynamicHandler"`


FireMethodNotAllowed [bool](/builtin#bool) `ini:"fire_method_not_allowed" json:"fireMethodNotAllowed,omitempty" yaml:"FireMethodNotAllowed" toml:"FireMethodNotAllowed"`


DisableAutoFireStatusCode [bool](/builtin#bool) `` 


ResetOnFireErrorCode [bool](/builtin#bool) `ini:"reset_on_fire_error_code" json:"resetOnFireErrorCode,omitempty" yaml:"ResetOnFireErrorCode" toml:"ResetOnFireErrorCode"`


URLParamSeparator *[string](/builtin#string) `ini:"url_param_separator" json:"urlParamSeparator,omitempty" yaml:"URLParamSeparator" toml:"URLParamSeparator"`


EnableOptimizations [bool](/builtin#bool) `ini:"enable_optimizations" json:"enableOptimizations,omitempty" yaml:"EnableOptimizations" toml:"EnableOptimizations"`


EnableProtoJSON [bool](/builtin#bool) `ini:"enable_proto_json" json:"enableProtoJSON,omitempty" yaml:"EnableProtoJSON" toml:"EnableProtoJSON"`


EnableEasyJSON [bool](/builtin#bool) `ini:"enable_easy_json" json:"enableEasyJSON,omitempty" yaml:"EnableEasyJSON" toml:"EnableEasyJSON"`


DisableBodyConsumptionOnUnmarshal [bool](/builtin#bool) `` 


FireEmptyFormError [bool](/builtin#bool) `ini:"fire_empty_form_error" json:"fireEmptyFormError,omitempty" yaml:"FireEmptyFormError" toml:"FireEmptyFormError"`


TimeFormat [string](/builtin#string) `ini:"time_format" json:"timeFormat,omitempty" yaml:"TimeFormat" toml:"TimeFormat"`


Charset [string](/builtin#string) `ini:"charset" json:"charset,omitempty" yaml:"Charset" toml:"Charset"`


PostMaxMemory [int64](/builtin#int64) `ini:"post_max_memory" json:"postMaxMemory" yaml:"PostMaxMemory" toml:"PostMaxMemory"`


LocaleContextKey [string](/builtin#string) `ini:"locale_context_key" json:"localeContextKey,omitempty" yaml:"LocaleContextKey" toml:"LocaleContextKey"`


LanguageContextKey [string](/builtin#string) `ini:"language_context_key" json:"languageContextKey,omitempty" yaml:"LanguageContextKey" toml:"LanguageContextKey"`


LanguageInputContextKey [string](/builtin#string) `` 


VersionContextKey [string](/builtin#string) `ini:"version_context_key" json:"versionContextKey" yaml:"VersionContextKey" toml:"VersionContextKey"`


VersionAliasesContextKey [string](/builtin#string) `` 


ViewEngineContextKey [string](/builtin#string) `ini:"view_engine_context_key" json:"viewEngineContextKey,omitempty" yaml:"ViewEngineContextKey" toml:"ViewEngineContextKey"`


ViewLayoutContextKey [string](/builtin#string) `ini:"view_layout_context_key" json:"viewLayoutContextKey,omitempty" yaml:"ViewLayoutContextKey" toml:"ViewLayoutContextKey"`


ViewDataContextKey [string](/builtin#string) `ini:"view_data_context_key" json:"viewDataContextKey,omitempty" yaml:"ViewDataContextKey" toml:"ViewDataContextKey"`


FallbackViewContextKey [string](/builtin#string) `` 


RemoteAddrHeaders [][string](/builtin#string) `ini:"remote_addr_headers" json:"remoteAddrHeaders,omitempty" yaml:"RemoteAddrHeaders" toml:"RemoteAddrHeaders"`


RemoteAddrHeadersForce [bool](/builtin#bool) `` 


RemoteAddrPrivateSubnets [][netutil](/github.com/kataras/iris/v12@v12.2.11/core/netutil).[IPRange](/github.com/kataras/iris/v12@v12.2.11/core/netutil#IPRange) `` 


SSLProxyHeaders map[[string](/builtin#string)][string](/builtin#string) `ini:"ssl_proxy_headers" json:"sslProxyHeaders" yaml:"SSLProxyHeaders" toml:"SSLProxyHeaders"`


HostProxyHeaders map[[string](/builtin#string)][bool](/builtin#bool) `ini:"host_proxy_headers" json:"hostProxyHeaders" yaml:"HostProxyHeaders" toml:"HostProxyHeaders"`


Other map[[string](/builtin#string)]interface{} `ini:"other" json:"other,omitempty" yaml:"Other" toml:"Other"`

}

Configuration holds the necessary settings for an Iris Application instance. All fields are optionally, the default values will work for a common web application.

A Configuration value can be passed through `WithConfiguration` Configurator. Usage: conf := iris.Configuration{ ... } app := iris.New() app.Configure(iris.WithConfiguration(conf)) OR app.Run/Listen(..., iris.WithConfiguration(conf)).

func DefaultConfiguration() Configuration

DefaultConfiguration returns the default configuration for an iris station, fills the main Configuration

TOML reads Configuration from a toml-compatible document file. Read more about toml's implementation at:https://github.com/toml-lang/toml

Accepts the absolute path of the configuration file. An error will be shown to the user via panic with the error message. Error may occur when the file does not exist or is not formatted correctly.

Note: if the char '~' passed as "filename" then it tries to load and return the configuration from the $home_directory + iris.tml, see `WithGlobalConfiguration` for more information.

Usage: app.Configure(iris.WithConfiguration(iris.TOML("myconfig.tml"))) or app.Run(iris.Runner, iris.WithConfiguration(iris.TOML("myconfig.tml"))).

YAML reads Configuration from a configuration.yml file.

Accepts the absolute path of the cfg.yml. An error will be shown to the user via panic with the error message. Error may occur when the cfg.yml does not exist or is not formatted correctly.

Note: if the char '~' passed as "filename" then it tries to load and return the configuration from the $home_directory + iris.yml, see `WithGlobalConfiguration` for more information.

Usage: app.Configure(iris.WithConfiguration(iris.YAML("myconfig.yml"))) or app.Run(iris.Runner, iris.WithConfiguration(iris.YAML("myconfig.yml"))).

GetCharset returns the Charset field.

func (c *Configuration) GetDisableAutoFireStatusCode() bool

GetDisableAutoFireStatusCode returns the DisableAutoFireStatusCode field.

func (c *Configuration) GetDisablePathCorrection() bool

GetDisablePathCorrection returns the DisablePathCorrection field.

func (c *Configuration) GetDisablePathCorrectionRedirection() bool

GetDisablePathCorrectionRedirection returns the DisablePathCorrectionRedirection field.

func (*Configuration) GetEnableDynamicHandler added in v12.2.4

func (c *Configuration) GetEnableDynamicHandler() bool

GetEnableDynamicHandler returns the EnableDynamicHandler field.

func (c *Configuration) GetEnableEasyJSON() bool

GetEnableEasyJSON returns the EnableEasyJSON field.

func (c *Configuration) GetEnableOptimizations() bool

GetEnableOptimizations returns the EnableOptimizations.

func (c *Configuration) GetEnablePathEscape() bool

GetEnablePathEscape returns the EnablePathEscape field.

func (c *Configuration) GetEnablePathIntelligence() bool

GetEnablePathIntelligence returns the EnablePathIntelligence field.

func (c *Configuration) GetEnableProtoJSON() bool

GetEnableProtoJSON returns the EnableProtoJSON field.

func (c *Configuration) GetFallbackViewContextKey() string

GetFallbackViewContextKey returns the FallbackViewContextKey field.

func (c *Configuration) GetFireEmptyFormError() bool

GetFireEmptyFormError returns the DisableBodyConsumptionOnUnmarshal field.

func (c *Configuration) GetFireMethodNotAllowed() bool

GetFireMethodNotAllowed returns the FireMethodNotAllowed field.

func (c *Configuration) GetForceLowercaseRouting() bool

GetForceLowercaseRouting returns the ForceLowercaseRouting field.

GetHostProxyHeaders returns the HostProxyHeaders field.

GetKeepAlive returns the KeepAlive field.

func (c *Configuration) GetLanguageContextKey() string

GetLanguageContextKey returns the LanguageContextKey field.

func (c *Configuration) GetLanguageInputContextKey() string

GetLanguageInputContextKey returns the LanguageInputContextKey field.

func (c *Configuration) GetLocaleContextKey() string

GetLocaleContextKey returns the LocaleContextKey field.

GetLogLevel returns the LogLevel field.

func (c *Configuration) GetNonBlocking() bool

GetNonBlocking returns the NonBlocking field.

func (c *Configuration) GetOther() map[string]interface{}

GetOther returns the Other field.

func (c *Configuration) GetPostMaxMemory() int64

GetPostMaxMemory returns the PostMaxMemory field.

func (c *Configuration) GetRemoteAddrHeaders() []string

GetRemoteAddrHeaders returns the RemoteAddrHeaders field.

func (c *Configuration) GetRemoteAddrHeadersForce() bool

GetRemoteAddrHeadersForce returns RemoteAddrHeadersForce field.

GetRemoteAddrPrivateSubnets returns the RemoteAddrPrivateSubnets field.

func (c *Configuration) GetResetOnFireErrorCode() bool

GetResetOnFireErrorCode returns ResetOnFireErrorCode field.

GetSSLProxyHeaders returns the SSLProxyHeaders field.

func (c *Configuration) GetSocketSharding() bool

GetSocketSharding returns the SocketSharding field.

GetTimeFormat returns the TimeFormat field.

GetTimeout returns the Timeout field.

func (c *Configuration) GetTimeoutMessage() string

GetTimeoutMessage returns the TimeoutMessage field.

func (c *Configuration) GetURLParamSeparator() *string

GetURLParamSeparator returns URLParamSeparator field.

GetVHost returns the VHost config field.

func (c *Configuration) GetVersionAliasesContextKey() string

GetVersionAliasesContextKey returns the VersionAliasesContextKey field.

func (c *Configuration) GetVersionContextKey() string

GetVersionContextKey returns the VersionContextKey field.

func (c *Configuration) GetViewDataContextKey() string

GetViewDataContextKey returns the ViewDataContextKey field.

func (c *Configuration) GetViewEngineContextKey() string

GetViewEngineContextKey returns the ViewEngineContextKey field.

func (c *Configuration) GetViewLayoutContextKey() string

GetViewLayoutContextKey returns the ViewLayoutContextKey field.

SetVHost sets the VHost config field.

type Configurator func(*Application)

Configurator is just an interface which accepts the framework instance.

It can be used to register a custom configuration with `Configure` in order to modify the framework instance.

Currently Configurator is being used to describe the configuration's fields values.

func NonBlocking() Configurator

NonBlocking sets the `Configuration.NonBlocking` field to true.

WithCharset sets the Charset setting.

See `Configuration`.

func WithConfiguration(c Configuration) Configurator

WithConfiguration sets the "c" values to the framework's configurations.

Usage: app.Listen(":8080", iris.WithConfiguration(iris.Configuration{/* fields here */ })) or iris.WithConfiguration(iris.YAML("./cfg/iris.yml")) or iris.WithConfiguration(iris.TOML("./cfg/iris.tml"))

func WithHostProxyHeader(headers ...string) Configurator

WithHostProxyHeader sets a HostProxyHeaders key value pair. Example: WithHostProxyHeader("X-Host"). See `Context.Host` for more.

WithKeepAlive sets the `Configuration.KeepAlive` field to the given duration.

WithLogLevel sets the `Configuration.LogLevel` field.

func WithOtherValue(key string, val interface{}) Configurator

WithOtherValue adds a value based on a key to the Other setting.

See `Configuration.Other`.

func WithPostMaxMemory(limit int64) Configurator

WithPostMaxMemory sets the maximum post data size that a client can send to the server, this differs from the overall request body size which can be modified by the `context#SetMaxRequestBodySize` or `iris#LimitRequestBodySize`.

Defaults to 32MB or 32 << 20 or 32*iris.MB if you prefer.

func WithRemoteAddrHeader(header ...string) Configurator

WithRemoteAddrHeader adds a new request header name that can be used to validate the client's real IP.

func WithRemoteAddrPrivateSubnet(startIP, endIP string) Configurator

WithRemoteAddrPrivateSubnet adds a new private sub-net to be excluded from `context.RemoteAddr`. See `WithRemoteAddrHeader` too.

func WithSSLProxyHeader(headerKey, headerValue string) Configurator

WithSSLProxyHeader sets a SSLProxyHeaders key value pair. Example: WithSSLProxyHeader("X-Forwarded-Proto", "https"). See `Context.IsSSL` for more.

WithSitemap enables the sitemap generator. Use the Route's `SetLastMod`, `SetChangeFreq` and `SetPriority` to modify the sitemap's URL child element properties. Excluded routes: - dynamic - subdomain - offline - ExcludeSitemap method called

It accepts a "startURL" input argument which is the prefix for the registered routes that will be included in the sitemap.

If more than 50,000 static routes are registered then sitemaps will be splitted and a sitemap index will be served in /sitemap.xml.

If `Application.I18n.Load/LoadAssets` is called then the sitemap will contain translated links for each static route.

If the result does not complete your needs you can take control and use the github.com/kataras/sitemap package to generate a customized one instead.

Example: https://github.com/kataras/iris/tree/main/_examples/sitemap.

func WithTimeFormat(timeformat string) Configurator

WithTimeFormat sets the TimeFormat setting.

See `Configuration`.

WithTimeout sets the `Configuration.Timeout` field to the given duration.

func WithoutRemoteAddrHeader(headerName string) Configurator

WithoutRemoteAddrHeader removes an existing request header name that can be used to validate and parse the client's real IP.

Look `context.RemoteAddr()` for more.

Context is the middle-man server's "object" for the clients.

A New context is being acquired from a sync.Pool on each connection. The Context is the most important thing on the iris's http flow.

Developers send responses to the client's request through a Context. Developers get request information from the client's request by a Context.

type ContextPatches struct {

}

ContextPatches contains the available global Iris context modifications.

func (*ContextPatches) GetDomain added in v12.2.0

GetDomain modifies the way a domain is fetched from `Context#Domain` method, which is used on subdomain redirect feature, i18n's language cookie for subdomain sharing and the rewrite middleware.

func (cp *ContextPatches) ResolveFS(patchFunc func(fsOrDir interface{}) fs.FS)

ResolveHTTPFS modifies the default way to resolve a filesystem by any type of value. It affects the view engine's filesystem resolver.

func (cp *ContextPatches) ResolveHTTPFS(patchFunc func(fsOrDir interface{}) http.FileSystem)

ResolveHTTPFS modifies the default way to resolve a filesystem by any type of value. It affects the Application's API Builder's `HandleDir` method.

SetCookieKVExpiration modifies the default cookie expiration time on `Context#SetCookieKV` method.

func (cp *ContextPatches) Writers() *ContextWriterPatches

Writers returns the available global Iris context modifications for REST writers.

type ContextPool[T any] interface {

Acquire(ctx [Context](#Context)) T

Release(T)

}

ContextPool is a pool of T. It's used to acquire and release custom context. Use of custom implementation or `NewContextPool`.

See `NewContextWrapper` and `NewContextPool` for more.

func NewContextPoolT any, contextPtr ContextSetterPtr[T] ContextPool[contextPtr]

NewContextPool returns a new ContextPool default implementation which uses sync.Pool to implement its Acquire and Release methods. The contextPtr is acquired from the sync pool and released back to the sync pool after the handler's execution. The contextPtr is passed to the handler as an argument. ThecontextPtr is not shared between requests. The contextPtr must implement the `ContextSetter` interface. The T must be a struct. The contextPtr must be a pointer of T.

Example: w := iris.NewContextWrapper(iris.NewContextPool[myCustomContext, *myCustomContext]())

type ContextSetter interface {

SetContext([Context](#Context))

}

ContextSetter is an interface which can be implemented by a struct to set the iris.Context to the struct. The receiver must be a pointer of the struct.

type ContextSetterPtr[T any] interface { *T ContextSetter }

ContextSetterPtr is a pointer of T which implements the `ContextSetter` interface. The T must be a struct.

type ContextWrapper[T any] struct {

}

ContextWrapper is a wrapper for handlers which expect a T instead of iris.Context.

See the `NewContextWrapper` function for more.

func NewContextWrapper[T any](pool ContextPool[T]) *ContextWrapper[T]

NewContextWrapper returns a new ContextWrapper. If pool is nil, a default pool is used. The default pool's AcquireFunc returns a zero value of T. The default pool's ReleaseFunc does nothing. The default pool is used when the pool is nil. Use the `iris.NewContextPool[T, *T]()` to pass a simple context pool. Then, use the `Handler` method to wrap custom handlers to iris ones.

Example: https://github.com/kataras/iris/tree/main/_examples/routing/custom-context

func (w *ContextWrapper[T]) FallbackViewFunc(handler func(ctx T, err ErrViewNotExist) error) FallbackViewFunc

FallbackViewFunc same as `Handler` but it converts a handler to FallbackViewFunc.

func (w *ContextWrapper[T]) Filter(handler func(T) bool) Filter

Filter same as `Handler` but it converts a handler to Filter.

func (*ContextWrapper[T]) Handler added in v12.2.8

func (w *ContextWrapper[T]) Handler(handler func(T)) Handler

Handler wraps the handler with the pool's Acquire and Release methods. It returns a new handler which expects a T instead of iris.Context. The T is the type of the pool. The T is acquired from the pool and released back to the pool after the handler's execution. The T is passed to the handler as an argument. The T is not shared between requests.

func (*ContextWrapper[T]) HandlerReturnDuration added in v12.2.8

HandlerReturnDuration same as `Handler` but it converts a handler which returns a time.Duration.

func (*ContextWrapper[T]) HandlerReturnError added in v12.2.8

func (w *ContextWrapper[T]) HandlerReturnError(handler func(T) error) func(Context) error

HandlerReturnError same as `Handler` but it converts a handler which returns an error.

func (*ContextWrapper[T]) Handlers added in v12.2.8

Handlers wraps the handlers with the pool's Acquire and Release methods.

func (w *ContextWrapper[T]) Pool() ContextPool[T]

Pool returns the pool, useful when manually Acquire and Release of custom context is required.

type ContextWriterPatches struct{}

ContextWriterPatches features the context's writers patches.

func (cwp *ContextWriterPatches) JSON(patchFunc func(ctx Context, v interface{}, options *JSON) error)

JSON sets a custom function which runs and overrides the default behavior of the `Context#JSON` method.

func (cwp *ContextWriterPatches) JSONP(patchFunc func(ctx Context, v interface{}, options *JSONP) error)

JSONP sets a custom function which runs and overrides the default behavior of the `Context#JSONP` method.

func (cwp *ContextWriterPatches) Markdown(patchFunc func(ctx Context, v []byte, options *Markdown) error)

Markdown sets a custom function which runs and overrides the default behavior of the `Context#Markdown` method.

func (cwp *ContextWriterPatches) XML(patchFunc func(ctx Context, v interface{}, options *XML) error)

XML sets a custom function which runs and overrides the default behavior of the `Context#XML` method.

func (cwp *ContextWriterPatches) YAML(patchFunc func(ctx Context, v interface{}, indentSpace int) error)

YAML sets a custom function which runs and overrides the default behavior of the `Context#YAML` method.

Cookie is a type alias for the standard net/http Cookie struct type. See `Context.SetCookie`.

CookieOption is the type of function that is accepted on context's methods like `SetCookieKV`, `RemoveCookie` and `SetCookie` as their (last) variadic input argument to amend the end cookie's form.

Any custom or builtin `CookieOption` is valid, see `CookiePath`, `CookieCleanPath`, `CookieExpires` and `CookieHTTPOnly` for more.

An alias for the `context.CookieOption`.

Dir implements FileSystem using the native file system restricted to a specific directory tree, can be passed to the `FileServer` function and `HandleDir` method. It's an alias of `http.Dir`.

DirCacheOptions holds the options for the cached file system. See `DirOptions`.

DirListRichOptions the options for the `DirListRich` helper function. A shortcut for the `router.DirListRichOptions`. Useful when `DirListRich` function is passed to `DirOptions.DirList` field.

DirOptions contains the optional settings that `FileServer` and `Party#HandleDir` can use to serve files and assets. A shortcut for the `router.DirOptions`, useful when `FileServer` or `HandleDir` is being used.

ErrPrivate if provided then the error saved in context should NOT be visible to the client no matter what. An alias for the `context.ErrPrivate`.

ErrViewNotExist reports whether a template was not found in the parsed templates tree.

ExecutionOptions is a set of default behaviors that can be changed in order to customize the execution flow of the routes' handlers with ease.

See `ExecutionRules` and `core/router/Party#SetExecutionRules` for more.

FallbackView is a helper to register a single template filename as a fallback when the provided tempate filename was not found.

FallbackViewFunc is a function that can be registered to handle view fallbacks. It accepts the Context and a special error which contains information about the previous template error. It implements the FallbackViewProvider interface.

See `Context.View` method.

FallbackViewLayout is a helper to register a single template filename as a fallback layout when the provided layout filename was not found.

Filter is just a type of func(Context) bool which reports whether an action must be performed based on the incoming request.

See `NewConditionalHandler` for more. An alias for the `context/Filter`.

type GlobalPatches struct {

}

GlobalPatches is a singleton features a uniform way to apply global/package-level modifications.

See the `Patches` package-level function.

func (p *GlobalPatches) Context() *ContextPatches

Context returns the available context patches.

type Guide interface {

AllowOrigin(originLine [string](/builtin#string)) [CompressionGuide](#CompressionGuide)

}

Guide is the simplify API builder. It's a step-by-step builder which can be used to build an Iris Application with the most common features.

NewGuide returns a simple Iris API builder.

Example Code:

package main

import ( "context" "database/sql" "time"

"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/x/errors"

)

func main() { iris.NewGuide(). AllowOrigin(""). Compression(true). Health(true, "development", "kataras"). Timeout(0, 20time.Second, 20*time.Second). Middlewares(). Services( // openDatabase(), // NewSQLRepoRegistry, NewMemRepoRegistry, NewTestService, ). API("/tests", new(TestAPI)). Listen(":80") }

// Recommendation: move it to /api/tests/api.go file. type TestAPI struct { TestService *TestService }

func (api *TestAPI) Configure(r iris.Party) { r.Get("/", api.listTests) }

func (api *TestAPI) listTests(ctx iris.Context) { tests, err := api.TestService.ListTests(ctx) if err != nil { errors.Internal.LogErr(ctx, err) return }

ctx.JSON(tests)

}

// Recommendation: move it to /pkg/storage/sql/db.go file. type DB struct { *sql.DB }

func openDatabase( your database configuration... ) *DB { conn, err := sql.Open(...) // handle error. return &DB{DB: conn} }

func (db *DB) Close() error { return nil }

// Recommendation: move it to /pkg/repository/registry.go file. type RepoRegistry interface { Tests() TestRepository

InTransaction(ctx context.Context, fn func(RepoRegistry) error) error

}

// Recommendation: move it to /pkg/repository/registry/memory.go file. type repoRegistryMem struct { tests TestRepository }

func NewMemRepoRegistry() RepoRegistry { return &repoRegistryMem{ tests: NewMemTestRepository(), } }

func (r *repoRegistryMem) Tests() TestRepository { return r.tests }

func (r *repoRegistryMem) InTransaction(ctx context.Context, fn func(RepoRegistry) error) error { return nil }

// Recommendation: move it to /pkg/repository/registry/sql.go file. type repoRegistrySQL struct { db *DB

tests TestRepository

}

func NewSQLRepoRegistry(db *DB) RepoRegistry { return &repoRegistrySQL{ db: db, tests: NewSQLTestRepository(db), } }

func (r *repoRegistrySQL) Tests() TestRepository { return r.tests }

func (r *repoRegistrySQL) InTransaction(ctx context.Context, fn func(RepoRegistry) error) error { return nil

// your own database transaction code, may look something like that:
// tx, err := r.db.BeginTx(ctx, nil)
// if err != nil {
//     return err
// }
// defer tx.Rollback()
// newRegistry := NewSQLRepoRegistry(tx)
// if err := fn(newRegistry);err!=nil{
// 	return err
// }
// return tx.Commit()

}

// Recommendation: move it to /pkg/test/test.go type Test struct { Name string db:"name" }

// Recommendation: move it to /pkg/test/repository.go type TestRepository interface { ListTests(ctx context.Context) ([]Test, error) }

type testRepositoryMem struct { tests []Test }

func NewMemTestRepository() TestRepository { list := []Test{ {Name: "test1"}, {Name: "test2"}, {Name: "test3"}, }

return &testRepositoryMem{
    tests: list,
}

}

func (r *testRepositoryMem) ListTests(ctx context.Context) ([]Test, error) { return r.tests, nil }

type testRepositorySQL struct { db *DB }

func NewSQLTestRepository(db *DB) TestRepository { return &testRepositorySQL{db: db} }

func (r *testRepositorySQL) ListTests(ctx context.Context) ([]Test, error) { query := SELECT * FROM tests ORDER BY created_at;

rows, err := r.db.QueryContext(ctx, query)
if err != nil {
    return nil, err
}
defer rows.Close()

tests := make([]Test, 0)
for rows.Next() {
    var t Test
    if err := rows.Scan(&t.Name); err != nil {
        return nil, err
    }
    tests = append(tests, t)
}

if err := rows.Err(); err != nil {
    return nil, err
}

return tests, nil

}

// Recommendation: move it to /pkg/service/test_service.go file. type TestService struct { repos RepoRegistry }

func NewTestService(registry RepoRegistry) *TestService { return &TestService{ repos: registry, } }

func (s *TestService) ListTests(ctx context.Context) ([]Test, error) { return s.repos.Tests().ListTests(ctx) }

type Handler

A Handler responds to an HTTP request. It writes reply headers and data to the Context.ResponseWriter() and then return. Returning signals that the request is finished; it is not valid to use the Context after or concurrently with the completion of the Handler call.

Depending on the HTTP client software, HTTP protocol version, and any intermediaries between the client and the iris server, it may not be possible to read from the Context.Request().Body after writing to the context.ResponseWriter(). Cautious handlers should read the Context.Request().Body first, and then reply.

Except for reading the body, handlers should not modify the provided Context.

If Handler panics, the server (the caller of Handler) assumes that the effect of the panic was isolated to the active request. It recovers the panic, logs a stack trace to the server error log, and hangs up the connection.

Component returns a new Handler which can be registered as a main handler for a route. It's a shortcut handler that renders the given component as HTML through Context.RenderComponent.

type HealthGuide interface {

Health(b [bool](/builtin#bool), env, developer [string](/builtin#string)) [TimeoutGuide](#TimeoutGuide)

}

HealthGuide is the 3rd step of the Guide. Health enables the /health route.

JSON the optional settings for JSON renderer.

It is an alias of the `context#JSON` type.

JSONP the optional settings for JSONP renderer.

It is an alias of the `context#JSONP` type.

JSONReader holds the JSON decode options of the `Context.ReadJSON, ReadBody` methods.

It is an alias of the `context#JSONReader` type.

Locale describes the i18n locale. An alias for the `context.Locale`.

A Map is an alias of map[string]interface{}.

Markdown the optional settings for Markdown renderer. See `Context.Markdown` for more.

It is an alias of the `context#Markdown` type.

type MiddlewareGuide interface {

RouterMiddlewares(handlers ...[Handler](#Handler)) [MiddlewareGuide](#MiddlewareGuide)

Middlewares(handlers ...[Handler](#Handler)) [ServiceGuide](#ServiceGuide)

}

MiddlewareGuide is the 5th step of the Guide. It registers one or more handlers to run before everything else (RouterMiddlewares) or before registered routes (Middlewares).

N is a struct which can be passed on the `Context.Negotiate` method. It contains fields which should be filled based on the `Context.Negotiation()` server side values. If no matched mime then its "Other" field will be sent, which should be a string or []byte. It completes the `context/context.ContentSelector` interface.

An alias for the `context.N`.

Party is just a group joiner of routes which have the same prefix and share same middleware(s) also. Party could also be named as 'Join' or 'Node' or 'Group' , Party chosen because it is fun.

Look the `core/router#APIBuilder` for its implementation.

A shortcut for the `core/router#Party`, useful when `PartyFunc` is being used.

ProblemOptions the optional settings when server replies with a Problem. See `Context.Problem` method and `Problem` type for more details.

It is an alias of the `context#ProblemOptions` type.

ProtoMarshalOptions is a type alias for protojson.MarshalOptions.

ProtoUnmarshalOptions is a type alias for protojson.UnmarshalOptions.

type ResultHandler added in v12.2.0

ResultHandler describes the function type which should serve the "v" struct value. See `APIContainer.UseResultHandler`.

Runner is just an interface which accepts the framework instance and returns an error.

It can be used to register a custom runner with `Run` in order to set the framework's server listen action.

Currently `Runner` is being used to declare the builtin server listeners.

See `Run` for more.

Addr can be used as an argument for the `Run` method. It accepts a host address which is used to build a server and a listener which listens on that host and port.

Addr should have the form of host:port, i.e localhost:8080 or :8080.

Second argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. An example of this use case can be found at:https://github.com/kataras/iris/blob/main/_examples/http-server/notify-on-shutdown/main.goLook at the `ConfigureHost` too.

See `Run` for more.

AutoTLS can be used as an argument for the `Run` method. It will start the Application's secure server using certifications created on the fly by the "autocert" golang/x package, so localhost may not be working, use it at "production" machine.

Addr should have the form of host:port, i.e mydomain.com:443.

The whitelisted domains are separated by whitespace in "domain" argument, i.e "iris-go.com", can be different than "addr". If empty, all hosts are currently allowed. This is not recommended, as it opens a potential attack where clients connect to a server by IP address and pretend to be asking for an incorrect host name. Manager will attempt to obtain a certificate for that host, incorrectly, eventually reaching the CA's rate limit for certificate requests and making it impossible to obtain actual certificates.

For an "e-mail" use a non-public one, letsencrypt needs that for your own security.

Note: `AutoTLS` will start a new server for you which will redirect all http versions to their https, including subdomains as well.

Last argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. An example of this use case can be found at:https://github.com/kataras/iris/blob/main/_examples/http-server/notify-on-shutdown/main.goLook at the `ConfigureHost` too.

Usage: app.Run(iris.AutoTLS("iris-go.com:443", "iris-go.com www.iris-go.com", "mail@example.com"))

See `Run` and `core/host/Supervisor#ListenAndServeAutoTLS` for more.

Listener can be used as an argument for the `Run` method. It can start a server with a custom net.Listener via server's `Serve`.

Second argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. An example of this use case can be found at:https://github.com/kataras/iris/blob/main/_examples/http-server/notify-on-shutdown/main.goLook at the `ConfigureHost` too.

See `Run` for more.

Raw can be used as an argument for the `Run` method. It accepts any (listen) function that returns an error, this function should be block and return an error only when the server exited or a fatal error caused.

With this option you're not limited to the servers that iris can run by-default.

See `Run` for more.

Server can be used as an argument for the `Run` method. It can start a server with a *http.Server.

Second argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. An example of this use case can be found at:https://github.com/kataras/iris/blob/main/_examples/http-server/notify-on-shutdown/main.goLook at the `ConfigureHost` too.

See `Run` for more.

TLS can be used as an argument for the `Run` method. It will start the Application's secure server.

Use it like you used to use the http.ListenAndServeTLS function.

Addr should have the form of host:port, i.e localhost:443 or :443. "certFileOrContents" & "keyFileOrContents" should be filenames with their extensions or raw contents of the certificate and the private key.

Last argument is optional, it accepts one or more `func(*host.Configurator)` that are being executed on that specific host that this function will create to start the server. Via host configurators you can configure the back-end host supervisor, i.e to add events for shutdown, serve or error. An example of this use case can be found at:https://github.com/kataras/iris/blob/main/_examples/http-server/notify-on-shutdown/main.goLook at the `ConfigureHost` too.

See `Run` for more.

type ServiceGuide interface {

Deferrables(closers ...func()) [ServiceGuide](#ServiceGuide)


WithPrefix(prefixPath [string](/builtin#string)) [ServiceGuide](#ServiceGuide)


WithoutPrefix() [ServiceGuide](#ServiceGuide)

Services(deps ...interface{}) [ApplicationBuilder](#ApplicationBuilder)

}

ServiceGuide is the 6th step of the Guide. It is used to register deferrable functions and, most importantly, dependencies that APIs can use.

SimpleUser is a simple implementation of the User interface.

Singleton is a structure which can be used as an embedded field on struct/controllers that should be marked as singletons on `PartyConfigure` or `MVC` Applications.

func (c Singleton) Singleton() bool

Singleton returns true as this controller is a singleton.

Supervisor is a shortcut of the `host#Supervisor`. Used to add supervisor configurators on common Runners without the need of importing the `core/host` package.

TimeoutGuide is the 4th step of the Guide. Timeout defines the http timeout, server read & write timeouts.

Tunnel is the Tunnels field of the TunnelingConfiguration structure.

TunnelingConfiguration contains configuration for the optional tunneling through ngrok feature. Note that the ngrok should be already installed at the host machine.

UnmarshalerFunc a shortcut, an alias for the `context#UnmarshalerFunc` type which implements the `context#Unmarshaler` interface for reading request's body via custom decoders, most of them already implement the `context#UnmarshalerFunc` like the json.Unmarshal, xml.Unmarshal, yaml.Unmarshal and every library which follows the best practises and is aligned with the Go standards.

See 'context#UnmarshalBody` for more.

Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-custom-via-unmarshaler/main.go

User is a generic view of an authorized client. See `Context.User` and `SetUser` methods for more. An alias for the `context/User` type.

ViewEngine is an alias of `context.ViewEngine`. See HTML, Blocks, Django, Jet, Pug, Ace, Handlebars and e.t.c.

XML the optional settings for XML renderer.

It is an alias of the `context#XML` type.