gin 怎么写个简单的中间件
gin 写个简单中间件,直接上例子: func GinServer() { engine := gin.Default() engine.Use(TestMiddleware) engine.GET("/", func(context *gin.Context) { context.JSON(http.StatusOK, "test") }) engine.Run(":8080") } func TestMiddleware(context *gin.Context) { fmt.Println("这是一个简单的中间件") } 这个例子最主要的方法是Use,看下Use方法 // Use attaches a global middleware to the router. ie. the middleware attached though Use() will be // included in the handlers chain for every single request. Even 404, 405, static files... // For example, this is the right place for a logger or error management middleware. func (engine *Engine) Use