REST-Based service design
Just wanted to walk through a quick REST-style API design exercise. Let’s suppose I want a service that lets folks maintain a list of favorite foods. Just as a quick strawman design, let’s walk through some URIs and supported operations:
GETon this URI returns a list of the current user’s favorites. List might be empty.
PUTon this URI overwrites an existing list of favorites.
DELETEon this URI sets the list of favorites to the empty list.
GETon this URI returns something (really, we just want a 200 status code) if the food is a favorite, or returns 404 if it is not.
DELETEon this URI un-favorites the food for the user.
PUTon this URI makes the food a favorite.
So, questions for the audience:
- Does this look reasonable?
- Does the use of
PUTlook right, or would you use
- How about the use of
DELETEto set the full list to the empty list? Does it make sense to
DELETEa URI and then be able to
GETit and have something be there?