DEV Community

Discussion on: How do you feel about the "misuse" of HTTP methods?

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

I guess it depends on what you're doing. Logic I use for determining things like this:

  • If there's a method that exactly matches the required semantics, use it. Usually, this translates to GET, PUT, DELETE, or PATCH in my experience.
  • If it doesn't modify server-side state and is cachable, it's a GET request.
  • If it does modify server-side state, but is idempotent, it's a PUT request unless some other request has specific semantics that fit better.
  • Otherwise, it's a POST request, probably with headers to prevent caching.

The thing is, in reality, if your request doesn't actually fit the first three cases, there arguably isn't a HTTP method that does exactly what you want, and it just makes the most sense to use the de-facto standard catch-all method.