441610
这里定义了router的中间件,
api.routes()实际返回的是dispatch函数
Router.prototype.routes = Router.prototype.middleware = function () {
var router = this;
var dispatch = function dispatch(ctx, next) {...}
dispatch.router = this;
return dispatch;
}
那在koa的application.js中compose遍历执行所有中间件时,为什么没有执行dispatch这个函数,而是在访问到对应的路由时,才会调用对应的dispatch?