Let's say I have I have an online store with a "shopping cart" feature and I want to implement an "empty cart" link in a RESTful way.
For simplicity, let's say my resources are a Cart that contains CartItems, each of which has a Product. My URIs might be:
# add a product to the current user's Cart POST /products/product_id/cart_items/ # remove a product from the current user's Cart DELETE /cart_items/cart_item_id/
If so, what would the RESTful URI for the "empty cart" link look like?
Instead, I could think of the Cart as a general-purpose holder for Actions (as described here):
# add a product # form data contains e.g., product_id=123&action=add POST /carts/cart_id/actions/ # remove a product # action_id is the id of the action adding product 123 DELETE actions/action_id # empty cart # form data contains action=clear POST /carts/cart_id/actions/
This approach seems more complicated than it needs to be. What would be a better way?