Call a Server-side Method on a Resource in a RESTful Way

后端 未结 8 1725
小蘑菇
小蘑菇 2020-12-02 03:14

Keep in mind I have a rudimentary understanding of REST. Let\'s say I have this URL:

http://api.animals.com/v1/dogs/1/

And now, I want to m

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 03:58

    REST is a resource oriented standard, it is not action driven as a RPC would be.

    If you want your server to bark, you should look into different ideas like JSON-RPC, or into websockets communication.

    Every try to keep it RESTful will fail in my opinion: you can issue a POST with the action parameter, you are not creating any new resources but as you may have side effects, you are safer.

提交回复
热议问题