Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modify response middleware example #1139

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 13 additions & 11 deletions examples/middleware/modifyResponse-middleware.js
Expand Up @@ -28,24 +28,26 @@ var util = require('util'),
colors = require('colors'),
http = require('http'),
connect = require('connect'),
app = connect(),
httpProxy = require('../../lib/http-proxy');

//
// Basic Connect App
//
connect.createServer(
function (req, res, next) {
var _write = res.write;
app.use(function (req, res, next) {
var _write = res.write;

res.write = function (data) {
_write.call(res, data.toString().replace("Ruby", "nodejitsu"));
}
next();
},
function (req, res) {
proxy.web(req, res);
res.write = function (data) {
_write.call(res, data.toString().replace("Ruby", "nodejitsu"));
}
).listen(8013);
next();
});

app.use(function (req, res) {
proxy.web(req, res)
});

http.createServer(app).listen(8013);

//
// Basic Http Proxy Server
Expand Down