by cletus · 14y ago · 0 comments
> POST /orders/42/pay
> POST /orders/42/ship
You don't put verbs in your URLs. This is really REST 101. I highly recommend Nobody understands REST or HTTP [1]. The above is exactly why you don't put verbs in URLs. Consider instead:
POST /payment { orderId=42, etc }
POST /shipment { orderId=42, etc }
is a much sounder RESTful API design.And in case anyone feels the need to suggest SOAP, I highly recommend the satiricial (but disturbingly accurate) The S stands for Simple [2].
[1]: http://blog.steveklabnik.com/posts/2011-07-03-nobody-underst...
[2]: http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-...
Having tried my hand at designing REST APIs for typical business systems a few times, I've noticed that state machines and transactions are everywhere. Making every resource a noun with the four basic REST verbs leads to a complex and extremely chatty design, whereas slipping a few extra verbs in here and there makes the API simpler, easier to understand, and more efficient.