简体   繁体   English

Sails.js:启用一些(但不是全部)REST蓝图路由?

[英]Sails.js: Enable some (but not all) REST blueprint routes?

In Sails.js v0.10, I can set whether or not to expose REST routes for controllers by setting the rest property in config\\blueprints.js or by setting _config: { rest: true } //or false in the controller definition. 在Sails.js v0.10中,我可以通过在config\\blueprints.js设置rest属性或通过在控制器定义中设置_config: { rest: true } //or false来设置是否为控制器公开REST路由。

Does anyone know if it's possible (and how) to set this for some REST routes but not all? 有谁知道是否有可能(以及如何)为某些REST路由而不是全部设置此路由?

For example, something like rest: { find: true, create: true, destroy: false, update: false } 例如,类似rest: { find: true, create: true, destroy: false, update: false }

I realize there are workarounds, but it would be nice to be able to set the defaults in one line. 我知道有解决方法,但是能够在一行中设置默认值会很好。

you can use policy setting like below. 您可以使用以下策略设置。 this will allow find but disable the other method. 这将允许查找,但禁用其他方法。

'Foo': {
    '*': false,
    'find': 'sessionAuth'
}

you can duplicate the default blueprint api and remove unwanted js files and in your routing bind the routes to the specific custom blueprint you made. 您可以复制默认的蓝图api并删除不需要的js文件,然后在路由中将路由绑定到您制作的特定自定义蓝图。 it will work 它会工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM