The 7 R's of Hypermedia
While most REST concepts are rather easy to grok, there is one concept which I found harder to understand at first: Hypermedia. Let it be that without this concept, you’re missing out on an extremely important strength of REST. Hypermedia enables you to build dumb - or smart, depending on your perspective - clients, which are mostly driven by the server. Practically, this is implemented as resources embedding links which allow the client to discover and navigate through your RESTful service.
Accidentally actually, I saw someone
tweet a link over the weekend to a Deep Fried Bytes episode, featuring Darrel Miller, where he talks about the seven R’s of Hypermedia. I listened to it on my morning commute, and the 56 minutes long show contained one of the best summaries on the uses of Hypermedia I’ve heard or read so far.
Here are some of my notes…
- Relations: Make your service discoverable and self-documenting by embedding links to related concepts.
- Embedded resources: Instead of embedding resources (for example: a company logo) into your client, and having to deal with specific storage techniques, make them available through your service and use built-in HTTP caching.
- Reference data: Provide links to where your client can find optional or required reference data. Populating a dropdownlist is a good example.
- Redistribution of effort: Instead of putting a dumb load balancer in front of your machines, you can use your links to refer certain functionality to a specific machine.
- Reduction of payload size: Show clients where they can get extra data. Think endless scrolling, or more detailed resources.
- Reflow: Allow the server to control the flow. The server can use links to dictate the next available steps in a business process.
- Restriction of functionality: The client can derive from the presence of a certain link whether a certain functionality is enabled or disabled.
You can find the full show here.