Recently I have been having a bunch of discussions around REST and whether or not the client participates in the RESTfulness of a system. Until now I’ve been saying that REST is confined to the server. I now realize that was wrong. Having a server which adheres to the constraints without clients that obey the same constraints will NOT yield the full benefits of REST. There’s a recent thread on this topic on the rest-discuss list here with some varying opinions.
My particular learning here is that when building RESTful systems we need to start paying more attention to the client*. The more I learn about REST, the more I realize that the client is where a lot of the hard work is.
Note: When I use client here I don’t mean the connector, I mean the user-agent which outside of HTTP circles is conventionally referred to as the client.
Here are the high level points.
- A RESTful system has a shared set of responsibilities between client and server. To truly realize the benefits of REST both client and server have to be good citizens.
- The server is the critical path. It’s responsibility is to expose resources in a manner that is consistent with adhering to the constraints. That means it sticks to the uniform interface (headers, media types), supports caching, uses hypermedia etc. If it does not, then it will prevent the benefits for all clients.
- The client must also adhere to REST constraints. If it does not, then the overall benefits of REST are not achieved within that system. It’s responsibility is to consume resources in a RESTful manner, i.e. use the uniform interface, consumes hypermedia, obeys caching requirements, etc.
- A client not obeying the rules does not necessarily remove all benefits of REST for the server, though it can impact them significantly if it is the ONLY client.
In many situations the clients (user agents) are out of you control as they are owned by third parties, so does that mean you should give up on trying to achieve the benefits of REST? I don’t think so, but it does mean more attention needs to be paid to clients / guidance given on how to build those clients in an evolvable fashion. Darrel Miller has started down this path in his recent post on a hypermedia client maturity model.
I think there’s much more discussion needed on this topic, For more RESTful systems to be realizable, we as industry need to offer more infrastructure / reusable components to make it easier for folks to build such clients.
Beyond that let me not forget to emphasize that you don’t necessarily NEED to build a system in a RESTful fashion. There are many factors that play in which is beyond the scope of this post.
Interested in your thoughts.