为什么这些 restify 函数以 "return next()" 结尾?

Why do these restify functions end with "return next()"?

我正在查看 restify 的文档。

http://restify.com/

我注意到有几个函数需要以 return next() 结尾。这里有一些例子;

function send(req, res, next) {
   res.send('hello ' + req.params.name);
   return next();
 }

 server.post('/hello', function create(req, res, next) {
   res.send(201, Math.random().toString(36).substr(3, 8));
   return next();
 });
 server.put('/hello', send);
 server.get('/hello/:name', send);
 server.head('/hello/:name', send);
 server.del('hello/:name', function rm(req, res, next) {
   res.send(204);
   return next();
 });

return next();的目的是什么?为什么函数需要以它结尾?

来自 Restify's website

Note the use of next(). You are responsible for calling next() in order to run the next handler in the chain. As below, you can pass an Error object in to have restify automatically return responses to the client.

所以基本上如果你的函数是链中的最后一个处理程序,你不需要调用 next() 因为没有办法知道你添加它并让 Restify 处理它。