Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/segment-boneyard/context-middleware

Attach req.context to all express requests
https://github.com/segment-boneyard/context-middleware

Last synced: about 7 hours ago
JSON representation

Attach req.context to all express requests

Awesome Lists containing this project

README

        

# context-middleware

Attach `req.context` to all [express](https://github.com/visionmedia/express) requests.

## Example

```js
var context = require('context-middleware');

var app = express();
app.use(context());
app.use('/user', function (req, res, next) {
var id = req.param('id');
users.get(id, function (err, user) {
req.context.user = user;
next();
});
});
```

## API

### context()

Generate a context middleware.

## License

```
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
```