this post was submitted on 22 Mar 2025
746 points (98.8% liked)
Programmer Humor
21881 readers
991 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I know an architect who designs APIs this way. Also includes a status code in the response object because why have one status code when you can have two, potentially contradictory, status codes?
I've seen the status code in a JSON response before: https://cloud.google.com/storage/docs/json_api/v1/status-codes#401-unauthorized
One reason I can think of for including it is that it may make it easier for the consumer to check the status code if it's in the JSON. Depending on how many layers of abstraction you have, your app may not have access to the raw HTTP response.
Although, yeah you lose the single source of truth though.
That sounds like either over-abstraction or bad abstraction then
Yea, I don't really see a scenario where you are both, making http requests (and therefore care about http responses), and also not able to see the response.
If you are using some wrapper client for an API, you wouldn't be dealing with the response anyway so it being in json isn't particularly helpful