5 ms·
Or, if you really want to be dogmatic, use DELETE when destroying something...in this case the customer account.
by binarymax 10y ago
Or, if you really want to be dogmatic, use DELETE when destroying something...in this case the customer account.
- arethuza 10y agoI don't think I would assume that "close" is the same as a delete.
- 72deluxe 10y agoThen why not cater for your own verb instead?
- caseysoftware 10y agoBecause you should never, never, never create your own verbs. The main reason APIs have become ubiquitous is that we have a shared understanding that follows us from API to API. That includes the concept of verbs, response codes, and how to interact with the nouns/resources. If you add verbs, you're breaking that agreement. Also, from a technical perspective, some of the internet infrastructure - servers, routers, etc - drop things they don't recognize. Heroku for years was dropping the PATCH verb despite recommending its use for customers' APIs.. and PATCH is in one of the specifications! Imagine what would happen to your custom verb. Don't create your own. Stick to the standards.
- zeveb 10y agoClosing it may not delete it, but simply mark it as closed.
- binarymax 10y agoIn CRUD, delete is rarely a hard delete that removes the data entirely. Best practice in most situations is setting a flag to mark it deleted. Closing an account is the same behavior - you are not purging the data, rather setting it to a closed/deleted/archived state.
- caseysoftware 10y agoYou're packing a lot of implied behavior - based on your experiences - into the DELETE verb instead of using the dictionary definition. If everyone has experience with similar systems, then you're fine. If others have worked with hard delete systems or aren't native English speakers, you're introducing ambiguity and context that isn't necessarily there.
- binarymax 10y agoUsing DELETE this way is absolutely not introducing or implying anything, this is best-practice REST. It signifies exactly the behavior I describe.
- pc86 10y agoDELETE simply means subsequent calls to GET should not return that object. So you can call DELETE on an account then your next GET returns a 404 because you deleted it from the database, or you can call DELETE and your next GET returns a 405 because the account has been closed and you're not allowed to call GET on a closed account. Both are totally within the spirit of what DELETE is supposed to accomplish, and I'm sure there are a half dozen other ways to architect it completely within the spirit of DELETE and REST as well.