Every request to my application should use some middleware. Using the Negroni docs I have implemented it like so:
func MyMiddleware(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
// do some stuff before
next(rw, r)
}
and elsewhere I use:
n.Use(negroni.HandlerFunc(MyMiddleware))
However, the middleware needs to receive an extra argument and I'm not sure how to build this in. At the moment I'm just setting the value as a global variable to make it available but I'm sure there's a more elegant way?
I would like to be able to do something like this:
n.Use(negroni.HandlerFunc(MyMiddleware(val)))