Node.js 快车JS next(‘路线’)

Node.js 快车JS next(‘路线’),node.js,express,routing,Node.js,Express,Routing,我刚刚了解到,这是尝试另一条路线的方法。例如,假设您有一个场景,其中有3条“获取”路线 app.get('/:customparam1', custom1); app.get('/:customparam2', custom2); app.get('/:customparam3', custom3); 对于每种方法,我们都有如下内容: custom# = function(req, res, next) { req.collections.findOne({req.params}, fun

我刚刚了解到,这是尝试另一条路线的方法。例如,假设您有一个场景,其中有3条“获取”路线

app.get('/:customparam1', custom1);
app.get('/:customparam2', custom2);
app.get('/:customparam3', custom3);
对于每种方法,我们都有如下内容:

custom# = function(req, res, next) {
  req.collections.findOne({req.params}, function(err, coll) {
    // do stuff here 
  })
}
我的问题是,express是否按照列出的顺序尝试这些路线?如果是这样的话,我想说我们想在custom1和custom2路由方法中编写下一个“路由”,而不是在custom3中编写,因为这将是检查的最终路由,这样说是否正确


我们的假设是,如果我们在最终路径上没有找到匹配项,那么在某个地方就存在程序员错误

你说得对。与中间件一样,路由也是按照定义的顺序执行的。谢谢。我也这么想,只是想确定一下。