Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
so what do you do when you want to delete something? `POST itemurl/delete`? or `GET itemurl?action=delete`?
-
@tosensei I prefer to do…
POST => items/delete/{id}
POST => items/create
POST => items/update
GET => items/{id} -
crisz82362y@GiddyNaya it works, but it doesn't follow the REST principles (just to say, there is a verb in the path)
-
Hazarth95012yIt's good for tagging. There's a lot of software that visualizes network communication, and if everything is POST then everything is the same color. You want more verbd simply to keep shit organized... In the same way you don't really need classes, packages or even folders, everything can be one long file... But man, that would be a hassle
-
Hazarth95012yAlso @GiddyNaya
By your Standard, in your example, your GET should be
GET /items/get/{id}
Otherwise you're mixing explicit path naming with requests typing. You should Stick to one if that's the case -
I like HTTP verbs for REST because they're simple. Why overengineer something with too many layers when the simple solution works just fine?
Over engineering only leads to unfortunate "status 200 {error: "bla bla failed"}" situations -
Root825992yGET — request data
POST — transfer data and make something happen
PUT — upload file or other large payload
PATCH — change data on server
DELETE — delete data/record on server
They all have their uses! -
@Root I always saw patch as a partial update and put as an overwrite/full update
-
I think one might wanna take a closer look again on why this is important...
Yeah. It's me, the nitbit freak.
I really really really really really really really recommend to read the specs.
https://httpwg.org/specs/...
The reason: It explains very well the thought process behind http methods.
Method is the key word here - that interestingly noone has used yet.
The http standard has very clear rules about methods - non safe vs safe, idempotent and thus retry safe vs non safe.
This is missing in an path based API. Simply put, a path based API specification without using methods is non compliant - it's up to the API specification to clarify this.
Needless to say that many APIs using HTTP methods implemented it wrong - but there is a standard that can be pointed to and thus a reason to say: Guys fix this shit, it's fucked up.
The other thing that methods make imho unbeatable is ACL and security.
Filtering based on paths is ridiculously stupid. It's a game one cannot win. you end up with a myriad clusterfuck of expressions that you cannot validate.
Filtering on a method? Plain stupid simple. 501… get the fuck off my lawn.
Not using methods is really throwing away a lot of good and well intended concepts that were way ahead of it's time. -
@GiddyNaya Are you a fan of dynamically typed languages? Because you have an URL segment of type: "usually ID except if it's equal to any of a couple magic strings" which is the lowest of shitty JS tricks in existence.
-
They each have different guarantees.
PUT - has body, repeatable
DELETE - no body, repeatable
GET - no body, idempotent
POST, PATCH - has body, stateful
DELET and PUT must be sent at least as many times as they are issued. GET need not be sent more than once if the cache is valid. I'm not entirely sure why PATCH is distinct, it would make a lot of sense to categorize POST as an unspecified RPC which may or may not create something(s), modify something(s) or delete something(s). In reality that's how it's used almost everywhere anyways, and most modifications can be recognized as a combination of creations and deletions, so even conceptually PATCH doesn't make sense.
Related Rants
-
fundor33313Client "Can you change your API? If a POST return 201 ours system crashes reading it" Me "Your system WHAT????...
-
bingumadness6The CEO at the company I work at has been telling our partners that our PIA is ready. It took me a week to fig...
-
Rohr4That moment when you finished your first REST API đ And you realise all it can do is useless âšī¸ But t...
I feel like the "DEL | PUT | PATCH" verb are overrated. I still cannot see it's usefulness to this day.
rant
request methods
rest api
verbs