mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 12:57:05 +00:00
fix all _examples to the newest mvc, add comments to those examples and add a package-level .Configure in order to make it easier for new users. Add a deprecated panic if app.Controller is used with a small tutorial and future resource link so they can re-write their mvc app's definitions
Former-commit-id: bf07696041be9e3d178ce3c42ccec2df4bfdb2af
This commit is contained in:
54
deprecated.go
Normal file
54
deprecated.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package iris
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kataras/iris/core/router"
|
||||
"github.com/kataras/iris/mvc"
|
||||
)
|
||||
|
||||
// Controller method is DEPRECATED, use the "mvc" subpackage instead, i.e
|
||||
// import "github.com/kataras/iris/mvc" and read its docs among with its new features at:
|
||||
// https://github.com/kataras/iris/blob/master/HISTORY.md#mo-01-jenuary-2018--v10
|
||||
func (app *Application) Controller(relPath string, c interface{}, _ ...interface{}) []*router.Route {
|
||||
name := mvc.NameOf(c)
|
||||
panic(fmt.Errorf(`"Controller" method is DEPRECATED, use the "mvc" subpackage instead.
|
||||
|
||||
PREVIOUSLY YOU USED TO CODE IT LIKE THIS:
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
// ...
|
||||
)
|
||||
|
||||
app.Controller("%s", new(%s), Struct_Values_Binded_To_The_Fields_Or_And_Any_Middleware)
|
||||
|
||||
NOW YOU SHOULD CODE IT LIKE THIS:
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/mvc"
|
||||
// ...
|
||||
)
|
||||
|
||||
// or use it like this: ).AddDependencies(...).Register(new(%s))
|
||||
mvc.Configure(app.Party("%s"), myMVC)
|
||||
|
||||
func myMVC(mvcApp *mvc.Application) {
|
||||
mvcApp.AddDependencies(
|
||||
Struct_Values_Dependencies_Binded_To_The_Fields_Or_And_To_Methods,
|
||||
Or_And_Func_Values_Dependencies_Binded_To_The_Fields_Or_And_To_Methods,
|
||||
)
|
||||
|
||||
mvcApp.Router.Use(Any_Middleware)
|
||||
|
||||
mvcApp.Register(new(%s))
|
||||
}
|
||||
|
||||
The new MVC implementation contains a lot more than the above,
|
||||
this is the reason you see more lines for a simple controller.
|
||||
|
||||
Please read more about the newest, amazing, features by navigating below
|
||||
https://github.com/kataras/iris/blob/master/HISTORY.md#mo-01-jenuary-2018--v1000`, // v10.0.0, we skip the number 9.
|
||||
relPath, name, name, relPath, name))
|
||||
}
|
||||
Reference in New Issue
Block a user