func Middleware() gin.HandlerFunc { return func(c *gin.Context) { // set a value in the request context c.Set("key", "value") // perform some operation on the request context // pass control to the next middleware in the chain c.Next() } }
router := gin.Default() // add the middleware to the router router.Use(Middleware())This package library is used by the gogs web framework to provide middleware for its web applications.