Express does not clone req
and res
. You can see that in this example the application:
var http = require('http');
var express = require('express');
var app = express();
var testReq, testRes;
app.use(function(req, res, next) {
console.log('middleware');
testReq = req;
testRes = res;
next();
});
app.get("*", function(req,res) {
console.log('route')
console.log('req the same? ' + (req === testReq));
console.log('res the same? ' + (res === testRes));
res.send(200);
});
http.createServer(app).listen(8080);
Test with curl
:
$ curl localhost:8080
- , req
res
. , req.user
.
Concurrency , Node.js - .
- get("*")
, , .