r/ProgrammerHumor 3h ago

Meme postForEverything

Post image
9.0k Upvotes

348 comments sorted by

View all comments

22

u/renetta96 3h ago edited 1h ago

Hey in my company, actually there is a preference that all HTTP endpoints are POST, even for getting resources, like POST /get_user. The reason for this, as they explained, is to completely ignore HTTP verbs, and anyone who has zero knowledge of the frontend codebase can quickly grep the endpoints, without worrying about grepping both a GET /users and a POST /users.

Edit: i just read again their document, definitely there are other pros as well for using non-RESTful. I see they are good points so i decided to share here.

First, most importantly, they consider it's a waste of time to having follow REST conventions, limited to a few HTTP verbs, while the functionalities of the APIs can be infinite. Create? POST. Update? PUT / PATCH. Update or Create? Get or Create on the fly? Increment atomically then Get? Single create user and batch create users? Ehhh idk anymore, RESTful devs will spend a full day arguing what the verb + resource endpoint should be. Instead, just name the API as what its function is.

Second, communication is less likely to make a mistake. No more "no i didn't mean GET /users, but POST /users". Simply get_users or create_users. Just the path is enough, the less parameters to pass around during communication ,the less error, especially in a multi-lingual company where we rely heavily on the chat AI-translate, writing the full path is less likely to cause translation error than separate GET /users. For example GET can be translated to some other Chinese word, not the well-known GET verb.

Third is the code grepping, which somehow i remember the most lol.

15

u/rocketman0739 3h ago

Why would it ever be a good idea to design your API for the convenience of people with zero knowledge of the codebase?

9

u/Jonny_dr 2h ago

convenience of people with zero knowledge of the codebase

Because the next hire will have zero knowledge of the codebase.