app.use(app.router);
を書かなくても動いたので、その意味を調べた。
app.js パターンA:
// ..略..
app.use(app.router);
app.use(express.errorHandler());
app.get('/', function(req, res, next){
// '/' へのアクセスでわざとエラーになるようにする
throw new Error();
});
// ..略..
app.js パターンB:
//app.use(app.router); // コメントアウト
app.use(express.errorHandler());
app.get('/', function(req, res, next){
throw new Error();
});
これらを実行すると、パターンA だけに errorHandler
が適用されていた。
app.router
を明示的に use
しない場合は、最初の app.get
(や post や all など) のときに暗黙的に app.router
を記述したのと同じになる。