top | item 14310975

(no title)

wtbob | 8 years ago

Another problem is that people want an RPC mechanism, when what they need is a state-transfer mechanism.

It turns out that the semantics of RPC — attractive as they undeniably are — are pretty poor for building real-world distributed systems, while those of REST as a pretty good (or at least better) fit.

discuss

order

throwaway55523|8 years ago

People need both. REST works well for CRUD operations that don't have complex side effects or constraints. What's often missing in this is intent. I just want to do "the thing" to this particular account or whatever.

Personally I like to very selectively add RPC actions on top of the base resource. Tacking an RPC action onto the resource URI allows you to encapsulate the intent of the user's action, handle all the updates required server side, and then return the updated representation.

boubiyeah|8 years ago

I almost always have both. I tend to use event sourcing and the intent is mandatory. There might be 20 reasons to modify one resource, each with its own list of side effects to later perform.

So it's usually POST resource/:id/action and that's fine.