diff --git a/HISTORY.md b/HISTORY.md index 3e5b8c39e9..d7ae32273e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -421,7 +421,7 @@ New Context Methods: - `Context.IsSSL() bool` reports whether the request is under HTTPS SSL (New `Configuration.SSLProxyHeaders` and `HostProxyHeaders` fields too). - `Context.GzipReader(enable bool)` method and `iris.GzipReader` middleware to enable future request read body calls to decompress data using gzip, [example](_examples/request-body/read-gzip). -- `Context.RegisterDependency(v interface{})` and `Context.RemoveDependency(typ reflect.Type)` to register/remove struct dependencies on serve-time through a middleware. +- `Context.RegisterDependency(v interface{})` and `Context.UnregisterDependency(typ reflect.Type)` to register/remove struct dependencies on serve-time through a middleware. - `Context.SetID(id interface{})` and `Context.GetID() interface{}` added to register a custom unique indetifier to the Context, if necessary. - `Context.GetDomain() string` returns the domain. - `Context.AddCookieOptions(...CookieOption)` adds options for `SetCookie`, `SetCookieKV, UpsertCookie` and `RemoveCookie` methods for the current request. diff --git a/_examples/mvc/authenticated-controller/main.go b/_examples/mvc/authenticated-controller/main.go index 672fd16a24..25a27955d5 100644 --- a/_examples/mvc/authenticated-controller/main.go +++ b/_examples/mvc/authenticated-controller/main.go @@ -76,7 +76,7 @@ type UnauthenticatedUserController struct{} // Get registers a route that will be executed when authentication is not passed // (see UserController.Get) too. func (c *UnauthenticatedUserController) Get() string { - return `custom action to redirect on authentication page` + return "custom action to redirect on authentication page" } // PostLogin serves diff --git a/_examples/routing/route-register-rule/main.go b/_examples/routing/route-register-rule/main.go index 6c22cf9181..31f5cb0826 100644 --- a/_examples/routing/route-register-rule/main.go +++ b/_examples/routing/route-register-rule/main.go @@ -23,6 +23,10 @@ func newApp() *iris.Application { // Stops the execution and fires an error before server boot. app.SetRegisterRule(iris.RouteError) + + // If ctx.StopExecution or StopWithXXX then the next route will be executed + // (see mvc/authenticated-controller example too). + app.SetRegisterRule(iris.RouteOverlap) */ app.Get("/", getHandler) diff --git a/configuration.go b/configuration.go index 2fa0f20609..925a457c4a 100644 --- a/configuration.go +++ b/configuration.go @@ -771,9 +771,15 @@ func (tc TunnelingConfiguration) createTunnel(tunnelAPIRequest ngrokTunnel, publ return nil } -// Configuration the whole configuration for an iris instance -// these can be passed via options also, look at the top of this file(configuration.go). -// Configuration is a valid OptionSetter. +// 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)). type Configuration struct { // vhost is private and set only with .Run/Listen methods, it cannot be changed after the first set. // It can be retrieved by the context if needed (i.e router for subdomains) diff --git a/context/context.go b/context/context.go index b3e6de2b5b..e29059ecf4 100644 --- a/context/context.go +++ b/context/context.go @@ -1163,13 +1163,13 @@ type Context interface { // through APIContainer(app.ConfigureContainer) or MVC(mvc.New) // in sake of minimum performance cost. // - // See `UnRegisterDependency` too. + // See `UnregisterDependency` too. RegisterDependency(v interface{}) - // UnRegisterDependency removes a dependency based on its type. + // UnregisterDependency removes a dependency based on its type. // Reports whether a dependency with that type was found and removed successfully. // // See `RegisterDependency` too. - UnRegisterDependency(typ reflect.Type) bool + UnregisterDependency(typ reflect.Type) bool // Application returns the iris app instance which belongs to this context. // Worth to notice that this function returns an interface @@ -5607,9 +5607,9 @@ func (ctx *context) RegisterDependency(v interface{}) { }) } -// UnRegisterDependency removes a dependency based on its type. +// UnregisterDependency removes a dependency based on its type. // Reports whether a dependency with that type was found and removed successfully. -func (ctx *context) UnRegisterDependency(typ reflect.Type) bool { +func (ctx *context) UnregisterDependency(typ reflect.Type) bool { cv := ctx.Values().Get(DependenciesContextKey) if cv != nil { m, ok := cv.(DependenciesMap)