Reputation: 59
What is the better way of using HTTP methods for REST:
First variant:
Send different HTTP methods to the same URL:
URL : item/{id} method : DELETE ---- DELETE item<br>
URL : item/{id} method : PUT ---- PUT item<br>
URL : item/{id} method : GET ---- GET item<br>
OR second:
Have a different URL for each HTTP method, and send each verb to its corresponding URL:
URL : deleteitem/{id} OR item/delete/{id} method: DELETE ---- DELETE item<br>
URL : putitem/{id} OR item/put/{id} method: PUT ---- PUT item<br>
URL : getitem/{id} OR item/get/{id} method: GET ---- GET item<br>
Upvotes: 3
Views: 2239
Reputation: 48702
The first variant, with the methods applied to the same URI, is the REST way of doing things. With REST, you do the following:
item/{id}
in your case.Upvotes: 5