minor

Gerasimos (Makis) Maropoulos 2019-07-23 17:51:39 +03:00
parent 620f77c42e
commit f8d3c0b494
No known key found for this signature in database
GPG Key ID: F169457BBDA4ACF4

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 "/":