按照官网的RESTful URL约定,可以通过router.resources()统一匹配到controller的方法


现在我遇到的问题,比如删除多个,我设计的路由如下:
router.delete('/api/role', controller.role.removes) =>实现传入用户选中的要删掉的数组,一次性删除
Controller:

Service:

但接口测试 router.resources('role', '/api/role', controller.role)
http://localhost:7001/api/role DELETE ID[]
无法自动对应到removes方法上。

想知道是EGG没有设计删除多个这个业务所自动匹配的命名规则像图一表格中规定的那几个业务,还是我哪里写错啦!!!
如果是没有设计如上传多个或删除多个 这样的匹配场景
路由共存也是可以的
router.delete('/api/role', controller.role.removes)
router.resources('role', '/api/role', controller.role)
这个没有特别标准的 api 设计,所以不做,你可以自己去扩展
Most helpful comment
如果是没有设计如上传多个或删除多个 这样的匹配场景
路由共存也是可以的
router.delete('/api/role', controller.role.removes)
router.resources('role', '/api/role', controller.role)