strongloop/express — pull request #2453 by izaakschroeder (2014-11-28 22:32:38+00:00)
Title: Expose layer to the current request.

Sometimes you wish to know something about the layer that is currently executing which cannot be provided by `req.route`, particularly because `req.route` is not available for the `.use()` family _and_ because the route object doesn't say which member of its stack it is currently executing.

Example usage might be something like:

```javascript
app.use(function middleware(req, res, next) {
req.layer.handle === middleware; // true
console.log(req.layer.name);
next();
});
```

This change is non-breaking unless some existing middleware sets a `.layer` property on the `req` object in which case this will overwrite it.