https://github.com/rubenv/connect-body-rewrite
Rewrite request bodies.
https://github.com/rubenv/connect-body-rewrite
Last synced: about 1 year ago
JSON representation
Rewrite request bodies.
- Host: GitHub
- URL: https://github.com/rubenv/connect-body-rewrite
- Owner: rubenv
- License: mit
- Created: 2013-11-14T14:07:53.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-07-03T06:29:47.000Z (about 12 years ago)
- Last Synced: 2025-05-25T13:54:21.332Z (about 1 year ago)
- Language: JavaScript
- Size: 205 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# connect-body-rewrite - middleware to rewrite response bodies.
> Rewrite response bodies for some requests.
[](https://travis-ci.org/rubenv/connect-body-rewrite)
This plugin allows you to write middleware methods that process the response
body of a call.
## Usage
Add the module:
```bash
npm install connect-body-rewrite --save
```
Specify an accept function and a rewrite function:
```javascript
app.use(require('connect-body-rewrite')({
accept: function (res) {
return res.getHeader('content-type').match(/text\/html/);
},
rewrite: function (body) {
return body.replace(/<\/body>/, "Copyright 2013