Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb4028ba

Browse files
costoloindexzero
authored andcommitted
Fix modify response middleware example (#1139)
* declare app variable to house middleware* remove deprecated connect.createServer() function call* specify middleware with app.use() and pass app middleware to an httpserver
1 parent77a9815 commitb4028ba

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

‎examples/middleware/modifyResponse-middleware.js‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,26 @@ var util = require('util'),
2828
colors=require('colors'),
2929
http=require('http'),
3030
connect=require('connect'),
31+
app=connect(),
3132
httpProxy=require('../../lib/http-proxy');
3233

3334
//
3435
// Basic Connect App
3536
//
36-
connect.createServer(
37-
function(req,res,next){
38-
var_write=res.write;
37+
app.use(function(req,res,next){
38+
var_write=res.write;
3939

40-
res.write=function(data){
41-
_write.call(res,data.toString().replace("Ruby","nodejitsu"));
42-
}
43-
next();
44-
},
45-
function(req,res){
46-
proxy.web(req,res);
40+
res.write=function(data){
41+
_write.call(res,data.toString().replace("Ruby","nodejitsu"));
4742
}
48-
).listen(8013);
43+
next();
44+
});
45+
46+
app.use(function(req,res){
47+
proxy.web(req,res)
48+
});
49+
50+
http.createServer(app).listen(8013);
4951

5052
//
5153
// Basic Http Proxy Server

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp