1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 02:47:04 +00:00

more checks about creating new instance of controller on each request - this time if all bindings are static then set them to the initial-devpassed controller and if the total number of lengths are equal with these static dependencies then we ignore the injector and use the initial controller on each request - maximize the performance when simple controller is used - need more cleanup before new release but I hope until Christmas iris developers will be amazed

Former-commit-id: 32ed69368d1df2c25cdb712bb7f0cf47b2e36c05
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-12-18 00:16:10 +02:00
parent 40b40fa7d3
commit d5a38a0cd6
19 changed files with 232 additions and 117 deletions

View File

@@ -25,13 +25,13 @@ func newApp(engine *Engine, subRouter router.Party) *Application {
}
}
// New returns a new mvc Application based on a "subRouter".
// New returns a new mvc Application based on a "party".
// Application creates a new engine which is responsible for binding the dependencies
// and creating and activating the app's controller(s).
//
// Example: `New(app.Party("/todo"))`.
func New(subRouter router.Party) *Application {
return newApp(NewEngine(), subRouter)
// Example: `New(app.Party("/todo"))` or `New(app)` as it's the same as `New(app.Party("/"))`.
func New(party router.Party) *Application {
return newApp(NewEngine(), party)
}
// Configure can be used to pass one or more functions that accept this
@@ -53,7 +53,7 @@ func (app *Application) Configure(configurators ...func(*Application)) *Applicat
// controller's methods, if matching.
//
// The dependencies can be changed per-controller as well via a `beforeActivate`
// on the `Register` method or when the controller has the `BeforeActivate(c *ControllerActivator)`
// on the `Register` method or when the controller has the `BeforeActivation(c *ControllerActivator)`
// method defined.
//
// It returns this Application.
@@ -75,16 +75,17 @@ func (app *Application) AddDependencies(values ...interface{}) *Application {
// It returns this Application.
//
// Example: `.Register(new(TodoController))`.
func (app *Application) Register(controller interface{}, beforeActivate ...func(*ControllerActivator)) *Application {
func (app *Application) Register(controller interface{}, beforeActivate ...func(BeforeActivation)) *Application {
app.Engine.Controller(app.Router, controller, beforeActivate...)
return app
}
// NewChild creates and returns a new Application which will be adapted
// to the "subRouter", it adopts
// the dependencies bindings from the parent(current) one.
// NewChild creates and returns a new MVC Application which will be adapted
// to the "party", it adopts
// the parent's (current) dependencies, the "party" may be
// a totally new router or a child path one via the parent's `.Router.Party`.
//
// Example: `.NewChild(irisApp.Party("/sub")).Register(new(TodoSubController))`.
func (app *Application) NewChild(subRouter router.Party) *Application {
return newApp(app.Engine.Clone(), subRouter)
// Example: `.NewChild(irisApp.Party("/path")).Register(new(TodoSubController))`.
func (app *Application) NewChild(party router.Party) *Application {
return newApp(app.Engine.Clone(), party)
}