2024-10-18 14:41:55 +08:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2024-10-18 17:21:19 +08:00
|
|
|
|
"github.com/Superdanda/hade/framework/gin"
|
2024-10-18 14:41:55 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test1() gin.HandlerFunc {
|
|
|
|
|
println("middle test1")
|
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
|
fmt.Println("middleware pre test1")
|
|
|
|
|
c.Next() // 调用Next往下调用,会自增contxt.index
|
|
|
|
|
fmt.Println("middleware post test1")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test2() gin.HandlerFunc {
|
|
|
|
|
println("middle test2")
|
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
|
fmt.Println("middleware pre test2")
|
|
|
|
|
c.Next() // 调用Next往下调用,会自增contxt.index
|
|
|
|
|
fmt.Println("middleware post test2")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test3() gin.HandlerFunc {
|
|
|
|
|
println("middle test3")
|
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
|
fmt.Println("middleware pre test3")
|
|
|
|
|
c.Next() // 调用Next往下调用,会自增contxt.index
|
|
|
|
|
fmt.Println("middleware post test3")
|
|
|
|
|
}
|
|
|
|
|
}
|