2
當我在/foo
上執行GET請求時,我的請求經過示例A中的第一個中間件功能,但繞過了示例B中的中間件功能?app.use()和app.get()之間的路徑處理方式不同
實施例A
GET「/ foo」的
app.use('/', function(req, res, next) {
console.log("req passes through here");
next();
}
app.get('/foo', function(req, res, next) {
console.log("then req passes through here");
}
實施例B
GET「/ foo」的
app.get('/', function(req, res, next) {
console.log("this part is bypassed...");
next();
}
app.get('/foo', function(req, res, next) {
console.log("then req passes through here");
}
那麼在例子B中如何安裝在/
上的中間件未被執行?