隐藏LoopBack PUT REST API方法

时间:2015-03-01 17:33:00

标签: node.js loopbackjs strongloop

如何在LoopBack中隐藏PUT REST API方法?我已经能够成功隐藏许多其他方法,但不能隐藏PUT方法。

> $ slc -v
strongloop v2.10.3 (node v0.10.35)
├── strong-arc@1.1.0
├── strong-build@1.0.3 (5a43a57)
├─┬ strong-supervisor@1.4.1 (c945bd1)
│ └── strong-agent@1.3.2
├── node-inspector@0.7.4
├── strong-deploy@1.1.4 (5e25e21)
├── strong-pm@1.7.2 (315d448)
├── strong-registry@1.1.4 (aab3dbb)
├── nodefly-register@0.3.3
└── generator-loopback@1.7.3 (9dc370f)

隐藏方法:

module.exports = function(Studio) {
    var isStatic = true;
    Studio.disableRemoteMethod('deleteById', isStatic); // DELETE /Studios/{id}
    Studio.disableRemoteMethod('create', isStatic); // POST /Studios
    Studio.disableRemoteMethod('upsert', isStatic); // PUT /Studios
    Studio.disableRemoteMethod('updateAll', isStatic); // POST /Studios/update
    Studio.disableRemoteMethod('updateAttributes', isStatic); // PUT /Studios/{id} *What is this supposed to be?*
};

如何隐藏PUT / Studios / {id}。文档表明它是updateAttributes,但是我尝试了所有可能没有成功的组合。 http://docs.strongloop.com/display/public/LB/Exposing+models+over+REST#ExposingmodelsoverREST-HidingmethodsandRESTendpoints

1 个答案:

答案 0 :(得分:2)

我认为你必须使用isStatic = false作为方法" updateAttributes" ...