Skip to content

Hypermedia

Decoupling Via Hypermedia In Practice

How does this sort of decoupling work in practice? Well, let’s say that we wish to remove the ability to transfer money from our bank to other banks as well as the ability to close accounts.

What does our hypermedia response for this GET request now look like?

HTTP/1.1 200 OK

<html>
  <body>
    <div>Account number: 12345</div>
    <div>Balance: $100.00 USD</div>
    <div>Links:
        <a href="/accounts/12345/deposits">deposits</a>
        <a href="/accounts/12345/withdrawals">withdrawals</a>
    </div>
  <body>
</html>

You can see that in this response, links for those two actions have been removed from the HTML. The browser simply render the new HTML to the user. To a rounding error, there are no clients sitting around using the old API. The API is encoded within and discovered through the hypermedia.

This means that we can dramatically change our API without breaking our clients.

This flexibility is the crux of the REST-ful network architecture and, in particular, of HATEOAS.

As you can see, despite much tighter application-level coupling between our front-end and back-end, we actually have more flexibility due to the network architecture decoupling afforded to us by the Uniform Interface aspect of REST-ful hypermedia systems.