On Wed, 26 Sep 2012, Thomas Schreiner wrote:
> What are your opinions about the design. Also any ideas about a different
> design are welcome.
If recovering things from the trash is important to you, have you
considered:
Tasks
* POST /Tasks => 204 or 303, Location: /Tasks/1 (task 1 created)
OR
PUT /Tasks/1 => 204 (task 1 created, you "had" the id already)
* DELETE /Tasks/1 => 204 (task now trashed)
Trash
* GET /Trash => 200 (list of items in trash)
* GET /Trash/1 => 200 (to get the resource that is in the trash)
* GET /Tasks/1 => 404 (it's not a task, it's in the trash)
* PUT /Tasks/1 => 204 (to "restore" the resource by putting it back)
* DELETE /Trash/1 => 204 (remove (for realz this time) on task)
* DELETE /Trash => 204 (empty the trash entirely)
That last one I probably wouldn't do, but instead GET /Trash and then
send many DELETEs if what I wanted to do was irrevocably delete the
stuff in the trash.
This gives you some nice humane URIs and uncomplicated grammar in the
API.
I'm sure there are plenty of other people here who would prefer that
the state of "being in the trash" be an attribute on the resource.
This could work fine, but if you did that, I think you lose the
simplicity which comes from the task resource remaining whole, whether
it is in the trash or not.
I think you're likely to get quite a few opinions on how to do this. I
would argue that there's no right way and that the best way depends on
your own style and the kinds of styles of interaction you want to
enable. For example are you targetting machine-based hypermedia
clients, or people writing HTTP clients?
--
Chris Dent
http://burningchrome.com/
[...]