|
|
@ -10,6 +10,25 @@ A simple object to represent an http response |
|
|
|
|
|
|
|
npm install http-response-object |
|
|
|
|
|
|
|
## Usage |
|
|
|
|
|
|
|
```js |
|
|
|
var Response = require('http-response-object'); |
|
|
|
var res = new Response(200, {}, new Buffer('A ok')); |
|
|
|
//res.statusCode === 200 |
|
|
|
//res.headers === {} |
|
|
|
//res.body === new Buffer('A ok') |
|
|
|
res.getBody(); |
|
|
|
// => new Buffer('A ok') |
|
|
|
|
|
|
|
var res = new Response(404, {'Header': 'value'}, new Buffer('Wheres this page')); |
|
|
|
//res.statusCode === 404 |
|
|
|
//res.headers === {header: 'value'} |
|
|
|
//res.body === new Buffer('Wheres this page') |
|
|
|
res.getBody(); |
|
|
|
// => throws error with `statusCode`, `headers` and `body` properties. |
|
|
|
``` |
|
|
|
|
|
|
|
## License |
|
|
|
|
|
|
|
MIT |