In a RESTful application, how do we differentiate between an “action” and an HTTP verb (GET, POST, PUT, DELETE)?
For example, as I understand it, a GET request to the resource /products should return a list of all products. A POST request to /products should create a new product. How, then, does the user request the original form which is used to create the product? My initial response would have been a GET request to the same URI, but as mentioned above, that should return a list of all products – not a blank form for creating a product.
In most frameworks I’ve researched, this problem is solved by making the “action” part of the URI. For example, a POST request to /products/create would create a new product, whereas a GET request to /products/create would give the blank form for creating a product. To get a list of all products would be a GET request to either /products or /products/get, /products/read, etc. depending on the framework in question. This approach resolves the ambiguity above, but it conflicts with what I’ve read about traditional REST design.
IMHO, the best option is to make the request method a part of controller’s action.
Lets say you are accessing
http://who.cares/product/42orhttp://who.cares/product/42/specification. This query to webserver would translate asProductcontroller. The actions name should be created by combining request method and command: