我想在我的express 3路由中使用http.Server.connections? 有沒有辦法得到它了?如何訪問Express 3路由器中的http.Server.connection屬性?
我應該只是 app.set('server',server);
express.createServer()的支持和快速的應用程序不再繼承http.Server
var app = express(),
server = http.createServer(app);
server.listen(8080);
...
module.exports = function (app) {
app.get('/connections', function (req, res) {
res.send({
connections: app.connections
// app != http.Server in express 3
});
});
};
重要的是要在這裏指出,app.listen()不返回正常的HTTP服務器,因此您必須手動創建一個服務器來訪問服務器的方法 – BHBH