2 ms·
Yep, there's absolutely no reason an application ought to be guessing URLs, and therefore no reason it should ever be requesting /api/v1/employees/69 where empl
by NoGravitas 4y ago
Yep, there's absolutely no reason an application ought to be guessing URLs, and therefore no reason it should ever be requesting /api/v1/employees/69 where employee 69 doesn't exist. If it does, it's playing silly buggers exactly as much as if it were to request /api/v69/nice/. Any user resources it needs to access will have had URLs provided to the application by another page.
- Spivak 4y agoExample Code: users = http.client.get("https://yourapi.com/users") # Frobulate each user for user in users: user = http.client.post(user.frobulate_url) # While this is running somewhere on the other side of # the world someone deletes one of the users. Oops. Assuming, users (i.e developers) will just never mistype a URL so you don't have to give useful feedback is just like being a bad netzen.
- NoGravitas 4y agoThat's a fair example. And returning 404 (Not Found) or 410 (Gone) is the most useful kind of feedback. More explanation in the body of the 404 response is helpful too, of course.