mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +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
|
what suits you best with Iris, low-level handlers: performance
|
||||||
or high-level controllers: easier to maintain and smaller codebase on large applications.
|
or high-level controllers: easier to maintain and smaller codebase on large applications.
|
||||||
|
|
||||||
|
**Read the comments very careful**
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -226,14 +228,22 @@ func (c *ExampleController) GetHello() interface{} {
|
||||||
// and of course before the server ran.
|
// and of course before the server ran.
|
||||||
// After version 9 you can also add custom routes for a specific controller's methods.
|
// After version 9 you can also add custom routes for a specific controller's methods.
|
||||||
// Here you can register custom method's handlers
|
// 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,
|
// use the standard router with `ca.Router` to
|
||||||
// and add dependencies that will be binded to a controller's fields or method function's input arguments.
|
// 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) {
|
func (c *ExampleController) BeforeActivation(b mvc.BeforeActivation) {
|
||||||
anyMiddlewareHere := func(ctx iris.Context) {
|
anyMiddlewareHere := func(ctx iris.Context) {
|
||||||
ctx.Application().Logger().Warnf("Inside /custom_path")
|
ctx.Application().Logger().Warnf("Inside /custom_path")
|
||||||
ctx.Next()
|
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,
|
// or even add a global middleware based on this controller's router,
|
||||||
// which in this example is the root "/":
|
// which in this example is the root "/":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user