Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/segment-boneyard/context-middleware
- Owner: segment-boneyard
- Created: 2013-12-11T22:06:37.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-20T02:52:15.000Z (over 9 years ago)
- Last Synced: 2024-04-09T16:31:02.916Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 95.7 KB
- Stars: 4
- Watchers: 39
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
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 \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
```