1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

replace ioutil with io package and other minor improvements

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-06-17 22:03:18 +03:00
parent 20d2855a66
commit ef2643b046
108 changed files with 1069 additions and 1021 deletions

View File

@@ -9,9 +9,11 @@ else as well, otherwise I am going with the first one:
```go
// 1
mvc.Configure(app.Party("/user"), func(m *mvc.Application) {
m.Router.Use(cache.Handler(10*time.Second))
})
mvc.Configure(app.Party("/user"), func(m *mvc.Application) {
m.Router.Use(cache.Handler(10*time.Second))
})
```
```go
@@ -32,10 +34,12 @@ mvc.Configure(userRouter, ...)
```go
// 4
// same:
app.PartyFunc("/user", func(r iris.Party){
r.Use(cache.Handler(10*time.Second))
mvc.Configure(r, ...)
})
app.PartyFunc("/user", func(r iris.Party){
r.Use(cache.Handler(10*time.Second))
mvc.Configure(r, ...)
})
```
If you want to use a middleware for a single route,
@@ -48,16 +52,18 @@ then you just call it on the method:
var myMiddleware := myMiddleware.New(...) // this should return an iris/context.Handler
type UserController struct{}
func (c *UserController) GetSomething(ctx iris.Context) {
// ctx.Proceed checks if myMiddleware called `ctx.Next()`
// inside it and returns true if so, otherwise false.
nextCalled := ctx.Proceed(myMiddleware)
if !nextCalled {
return
}
// else do the job here, it's allowed
}
func (c *UserController) GetSomething(ctx iris.Context) {
// ctx.Proceed checks if myMiddleware called `ctx.Next()`
// inside it and returns true if so, otherwise false.
nextCalled := ctx.Proceed(myMiddleware)
if !nextCalled {
return
}
// else do the job here, it's allowed
}
```
And last, if you want to add a middleware on a specific method

View File

@@ -1,8 +1,10 @@
/*Package main shows how to add done handlers in an MVC application without
/*
Package main shows how to add done handlers in an MVC application without
the necessity of `ctx.Next()` inside the controller's methods.
When we want the `Done` handlers of that specific mvc app's `Party`
to be executed but we don't want to add `ctx.Next()` on the `exampleController#EndRequest`*/
to be executed but we don't want to add `ctx.Next()` on the `exampleController#EndRequest`
*/
package main
import (