I'm using Gin-Gonic and I'm creating a custom middleware. See: https://github.com/gin-gonic/gin#custom-middleware
Is there a reason why the middlewares in the doc are written as such:
func MyMiddleware() gin.HandlerFunc {
return func (c *gin.Context) {
// middleware
}
}
r := gin.New()
r.Use(MyMiddleware())
When I could simply write it like this:
func MyMiddleware(c *gin.Context) {
// middleware
}
r := gin.New()
r.Use(MyMiddleware)
Thanks for your help!