You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var express = require('express')
var app = express();
app.use(function(req,res,next){
// do something
});
//等同以下代码
var http = require('http');
function express(){
var funcs = [];
var expr = function(req,res){
var i = 0;
function next(){
var task = funcs[i++];
if(!task) return;
task(req,res,next);
}
next();
}
expr.use=function(f){
funcs.push(f);
}
return expr;
var express = require('express')
var app = express();
app.use(function(req,res,next){
// do something
});
//等同以下代码
var http = require('http');
function express(){
var funcs = [];
}
var app = express();
app.use(function(req,res,next){
console.log('haha');
next();
});
app.use(function(req,res,next){
console.log('hehe');
next();
});
app.use(function(req,res){
res.end("there is nothing happened");
});
http.createServer(app).listen('3000', function(){
console.log('Express server listening on port 3000');
});
The text was updated successfully, but these errors were encountered: