mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
minor
parent
620f77c42e
commit
f8d3c0b494
16
MVC.md
16
MVC.md
|
@ -166,6 +166,8 @@ but you can choose
|
|||
what suits you best with Iris, low-level handlers: performance
|
||||
or high-level controllers: easier to maintain and smaller codebase on large applications.
|
||||
|
||||
**Read the comments very careful**
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
|
@ -226,14 +228,22 @@ func (c *ExampleController) GetHello() interface{} {
|
|||
// and of course before the server ran.
|
||||
// After version 9 you can also add custom routes for a specific controller's methods.
|
||||
// Here you can register custom method's handlers
|
||||
// use the standard router with `ca.Router` to do something that you can do without mvc as well,
|
||||
// and add dependencies that will be binded to a controller's fields or method function's input arguments.
|
||||
// use the standard router with `ca.Router` to
|
||||
// do something that you can do without mvc as well,
|
||||
// and add dependencies that will be binded to
|
||||
// a controller's fields or method function's input arguments.
|
||||
func (c *ExampleController) BeforeActivation(b mvc.BeforeActivation) {
|
||||
anyMiddlewareHere := func(ctx iris.Context) {
|
||||
ctx.Application().Logger().Warnf("Inside /custom_path")
|
||||
ctx.Next()
|
||||
}
|
||||
b.Handle("GET", "/custom_path", "CustomHandlerWithoutFollowingTheNamingGuide", anyMiddlewareHere)
|
||||
|
||||
b.Handle(
|
||||
"GET",
|
||||
"/custom_path",
|
||||
"CustomHandlerWithoutFollowingTheNamingGuide",
|
||||
anyMiddlewareHere,
|
||||
)
|
||||
|
||||
// or even add a global middleware based on this controller's router,
|
||||
// which in this example is the root "/":
|
||||
|
|
Loading…
Reference in New Issue
Block a user