Question

In modern web design, there's a clear demarcation between GET and POST requests. GET is used to retrieve info in contexts where security is not important. POST transfers data without appending to the URL and should be used to manipulate data on a server.

HTTP specifies that PUT should be used to update individual records and DELETE should be used to delete data. But these two request types are hardly ever implemented in modern web design. HTML forms only allow GET and POST and a good number of web servers block the PUT and DELETE keywords by default.

Is there any place in modern web design for PUT and DELETE requests? If so, what are some examples?

Was it helpful?

Solution

Here's a real life example from a social media site I coded on contract:

Every user has a (username)/blog route.

GET to that route shows their entire blog (most recent several posts, and an ajax call with certain params fetches more).

POST to that route creates a new blog post on that user's blog.

After a POST, a new route is created at .../(post id)/(slug)/

A GET to that fetches that post only.

A PUT edits that post without changing the routes.

A DELETE deletes the post.

We use the same scheme for videos, comments, etc.

This is based on the REST design strategy. POST is for the creation of a new resource. PUT is for the replacement of an existing resource. DELETE deletes. GET fetches without changing the server's state.

The lack of HTML form support is not as big a deal nowadays since we ended up having to use JavaScript for form submission for other reasons anyways. And we do not have any problems related to webserver limitations, at least since Heroku removed their request routing HTTP methods limitations one year ago.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top