未find在Sailsjs中find的路线

基于Sailsjs文档 ,可以在路由文件中添加一个语法如下的响应:

module.exports.routes = { '/foo': {response: 'notFound'} }; 

这会在/response目录中searchnotFound.js文件,这个文件位于那里。

所以在我的routes.js文件中,我已经添加了这个作为其他路线的末端,以便捕获找不到的路线,就像这样:

 module.exports.routes = { 'get /myroute/:myPara/': 'MyController.getAll', 'get /myroute/:myPara/': 'MyController.getOne', 'post /myroute/:myPara/': 'MyController.create', '/*' : {response: 'notFound'} }; 

我意识到,从来没有find最后的路线,我也试图删除斜线(做'*' ),但没有任何工作。

我错过了什么吗? 谢谢!

帆已经照顾了404没有find: 在这里

Sails调用res.notFound(),你可以覆盖默认的notFound():

res.notFound() (像其他用户域响应方法)可以被覆盖或修改。 它运行/responses/notFound.js中定义的响应方法,该方法在新生成的Sails应用程序中自动捆绑。 如果您的应用中不存在notFound.js响应方法,则Sails将隐式使用默认行为。