开发者

CakePHP RESTful actions

开发者 https://www.devze.com 2022-12-20 07:22 出处:网络
I have successfully made my 4 CRUD actions restful by using mapResources in the router config. but I need to filter which ones are actually RESTful. How do I filter which ones are RESTful? I don\'t wa

I have successfully made my 4 CRUD actions restful by using mapResources in the router config. but I need to filter which ones are actually RESTful. How do I filter which ones are RESTful? I don't want to allow rest calls to the delete actions for example but I do however need to keep the delete actio开发者_StackOverflown so I can moderate.


I think you're getting mixed up in buzzwords here. :-)

All actions are by definition RESTful, it's a concept built into the HTTP protocol. "Making an application RESTful" usually means, among other things, to actually use the concept of reacting differently to GET, POST, PUT or DELETE requests on the same URL. E.g.

GET    http://example.com/users      -> Receive a list of all users
POST   http://example.com/users      -> Creates (a) new user(s)
GET    http://example.com/user/42    -> Receives info about user #42
PUT    http://example.com/user/42    -> Edit/replace the information of user #42
DELETE http://example.com/user/42    -> Delete user #42

Therefore, even if you do nothing, every request is always RESTful, because every request is using one of these HTTP methods (usually GET).

I think what you're looking for is plain old user privileges handling using something like the AuthComponent.


I figured out what I need to do. I have to do some custom rest routing to enable the methods I want versus enabling them all.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号