Sails multiple handlers for the same route

谁说我不能喝 提交于 2019-12-02 03:07:07
eAbi

Ok, after searching for over than 1 week, I found the solution here. So everyone who's dealing with this and have problems calling multiple controllers here's how this can be achieved. From the gist:

Routes can now specify a list of targets, which will be run in order (this allows for binding chains of middleware directly to routes). Both controllers (controller.action) and arbitrary middleare (middleware) functions from the new, optional middleware directory can be specified, in any order:

{
    'post /signup': ['user.unique', 'user.create', 'verifyemail.send'],
    '/auth/logout': ['authenticated', 'auth.logout']
}

You can also still use classic {controller: 'foo', action: 'bar' } notation. And conveniently, miscellaneous strings are treated as redirects:

{
    // Alias '/logout' to '/auth/logout'
    'get /logout': '/auth/logout',
    '/thegoogle': 'http://google.com'
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!