no actions in the URL
during a short exchange on the REST discuss list today, someone asked the best way to REST-ify a publish/draft toggle for a web URI:
I've got articles in the system, and when I first add them they're in
draft mode. At some point I can publish them to make them public.
And at any time I can toggle between draft or published mode.
i replied thusly:
PUT /publish/1
PUT /draft/1
subbu pointed out the major flaw in my suggestion:
But that looks like a method-oriented URI and not a resource-oriented
URI. For example, what would
GET /publish/1
mean?
and bob haugen (blog?) puts it all out there:
Alternatively, you could
PUT /articles/1/mode
(the state of which is either "draft" or "published")
Because that is literally what you are doing, changing the state of
mode of the article, which appears to be somewhat independent of
changing the state of the contents of the article.
!bingo!
lesson (re)learned: keep 'actions' out of the URI
thanks bob and subbu for the gentle whack on the back of the head.