An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# connect-body-rewrite - middleware to rewrite response bodies.

> Rewrite response bodies for some requests.

[![Build Status](https://travis-ci.org/rubenv/connect-body-rewrite.png?branch=master)](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