调用和返回函数有什么区别?

What is the difference between calling and returning a function?

我正在试验一些快速路线,我正在尝试做这样的事情:

route.get('/guest', GuestHandler.getAll)

和 'getAll' 将被定义为(不起作用):

GuestHandler.getAll = function() {
     return function(req, res) {
          res.send('hello world');
     }
};

这个有效:

GuestHandler.getAll = function(req, res) {
     res.send('hello world');
}

如何在不明确执行后者的情况下做出类似前者的作品?

How can I make something like the former work without explicitly doing the latter?

您必须 调用 getAll 才能获得函数 returns:

route.get('/guest', GuestHandler.getAll())
// Change is here ---------------------^^