This misses the elephant in the room. The REST-inspired API that requires 10,000 API calls to do something that could be done in 1. This is a disaster from a simple performance perspective. There is no simple way to build transactions on top of REST so if you need to do something that involves updating more than one data record you really are best off updating them all in one API call. When you are writing a web fron…
REST Anti-patterns
111–120 of 133 posts
Re: REST Anti-patterns
#112Re: REST Anti-patterns
#113Earlier quoted context omitted.
> "business is an exchange of documents" Did you just make up this phrase? It's really good!
You would probably like reading [1] by Dan North. [1]: https://dannorth.net/classic-soa/
Imagine you want to implement a vacation-booking service
as part of an enterprise system. The first step is to
remove any reference to computers or modern technology.
This will allow you to concentrate on the business
objectives of the service, without getting sidetracked by
technological considerations. In other words, it enables
you to separate the “what” from the “how.”
That's pretty great advice.Re: REST Anti-patterns
#114Re: REST Anti-patterns
#115No mention of the biggest single problem with REST as it's practiced: POST /login. You should use POST /session instead.
Re: REST Anti-patterns
#116Earlier quoted context omitted.
REST is just a representation of the underlying data. What does it matter if "status" is a database field or not? More specifically, it shouldn't have to matter to consumers. Because of the way REST and HTTP work, clients intuitively understand retrieving and modifying resources (via GET, POST, PUT, PATCH and DELETE). But they don't understand interacting with special-purpose endpoints (POST always implies "make a ne…
What if 'status' isn't a column in the account database? What if closed_accounts is a join table or something else? Then wouldn't adding a /close route be hiding idiosyncrasies in your data model, not the other way around? It seems like we spend a lot of time designing object relations that map a domain, but maybe not so much mapping domain-specific actions. Or would you consider all of the above bad practice?
If you're speaking HTML it can be as simple as:
Close Account
Or even:
Close Account
If you're speaking Siren (https://github.com/kevinswiber/siren): {
"actions": [
{
"title": "Close Account",
"method": "POST",
"href": "/close-account",
"type": "application/x-www-form-urlencoded",
"fields": [
{ "name": "acc_number", "type": "hidden", "value": "12345" }
]
}
]
}Re: REST Anti-patterns
#117Question 2#: What is the consensus around custom verbs? While I've never gone down this route, a few times I have been tempted.
Re: REST Anti-patterns
#118No mention of the biggest single problem with REST as it's practiced: POST /login. You should use POST /session instead.
What if i use JWT and thus have no concept of 'session' resources? You would actually create a token using username and password.
I think a JWT token represents a session, since it can expire and be disposed when logging out.
Re: REST Anti-patterns
#119Earlier quoted context omitted.
This depends on your data model. If "status" is just a property on the accounts resource and doesn't have further meaning, I would tend to agree with you. If "close" is an action or activity that acts upon an accounts resource, then his approach makes sense. Since the context is an account that we "need to close," I would assume the author is talking about something more complex than a database field. It's probably a…
> If "close" is an action or activity that acts upon an accounts resource, then his approach makes sense. Right. Particularly, if a closure request is a thing that has its own status, identity, and associated data elements, which one might wish to examine and interact with (and, while its possible that such interaction might not be possible for external users with privileges only on their own accounts, it might well…
POST /accounts/4402278/close
You would have something like
POST /accounts/4402278/closures
Re: REST Anti-patterns
#120No mention of the biggest single problem with REST as it's practiced: POST /login. You should use POST /session instead.