After studying some Middleware's I have still a question.

Have a look at the following working setup, It just attaches the do it function to the req object so that we can call it in any route just like `req.doit()`

But where does the **req, res, next** come from ?, 
I never passed them and I am even more curious how it works since the anonymous function (2.) is surrounded by another function (1.) which I even can pass arguments.

MiddleWareTest.js:

```
var test = function(options){ //1.)
    return function(req, res, next) { //2.)
        req.doit = function() {
            console.log('doit')
        }
        next();
    }
}
module.exports = test;

```

app.js:

```
...
var myMiddleware =  require('./MiddlewareTest.js')
app.use(myMiddleware())
...

```

Any suggestions to deepen my knowledge are welcome :)

~Marc