Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BackendStack21/on-http-end
Allows to capture HTTP response content and headers on request end.
https://github.com/BackendStack21/on-http-end
end headers http response stream
Last synced: 9 days ago
JSON representation
Allows to capture HTTP response content and headers on request end.
- Host: GitHub
- URL: https://github.com/BackendStack21/on-http-end
- Owner: BackendStack21
- License: mit
- Created: 2019-05-28T19:26:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-07T19:57:07.000Z (over 1 year ago)
- Last Synced: 2024-05-20T03:19:57.822Z (6 months ago)
- Topics: end, headers, http, response, stream
- Language: JavaScript
- Size: 61.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- cuban-opensource - on-http-end
README
# on-http-end
Allows to capture HTTP response content and headers on request end.
> Inspired by: https://github.com/kwhitley/apicache/blob/master/src/apicache.js## Install
```bash
npm i on-http-end
```## Usage
```js
const onEnd = require('on-http-end')
const http = require('http')const server = http.createServer((req, res) => {
onEnd(res, (payload) => {
console.log(payload)
})res.setHeader('my-header', 'value')
res.end('Hello Word!', 'utf-8')
})server.listen(3000)
```Output:
```bash
{
status: 200,
headers: [Object: null prototype] { 'my-header': 'value' },
data: 'Hello Word!',
encoding: 'utf-8'
}
```## Want to contribute?
This is your repo ;)> Note: We aim to be 100% code coverage, please consider it on your pull requests.