Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/koa-request-id
Add a request id
https://github.com/segment-boneyard/koa-request-id
Last synced: about 5 hours ago
JSON representation
Add a request id
- Host: GitHub
- URL: https://github.com/segment-boneyard/koa-request-id
- Owner: segment-boneyard
- Created: 2014-01-23T18:00:35.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-23T03:46:31.000Z (over 9 years ago)
- Last Synced: 2024-11-09T01:48:46.326Z (7 days ago)
- Language: JavaScript
- Size: 183 KB
- Stars: 12
- Watchers: 40
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# koa-request-id
Add a request id as `this.id`, if set reusing one from the querystring or
headers.[Express version](https://github.com/segmentio/request-id-middleware).
[![build status](https://secure.travis-ci.org/segmentio/koa-request-id.png)](http://travis-ci.org/segmentio/koa-request-id)## Example
```js
var koa = require('koa');
var requestId = require('koa-request-id');var app = koa();
app.use(requestId());
app.use(function*(){
this.body = this.id;
});app.listen(3000);
```Query it:
```bash
$ curl http://localhost:3000
23691882-abd8-4857-88f3-41a7f962aefd$ curl http://localhost:3000/?request-id=1337
1337$ curl -H "Request-id: 1337" http://localhost:3000
1337
```## Installation
```bash
$ npm install koa-request-id
```## License
MIT