Search⌘ K
AI Features

Creating a Hypermedia-Based Web Service

Explore the concepts of hypermedia and its benefits in REST APIs. Learn how to integrate Spring HATEOAS with Spring WebFlux to create rich JSON responses with navigational links. Understand how to build flexible, evolvable web services by combining domain objects with hypermedia links using Spring Boot.

Objective

So far, the JSON file we’ve been working with looks something like this:

{
   "id" : "item-1",
   "name" : "Alf alarm clock",
   "description" : "nothing I really need",
   "price" : 19.99
}

However, after this lesson, we’ll be looking at the following JSON file:

{
   "id" : "item-1",
   "name" : "Alf alarm clock",
   "description" : "nothing I really need",
   "price" : 19.99,
   "_links" : {
      "self" : {
         "href" : "http://localhost:8080/hypermedia/items/item-1"
      },
      "item" : {
         "href" : "http://localhost:8080/hypermedia/items"
      }
   }
}

Not only will we see snippets for the JSON outputs, but there will also be a separate snippet listing each hypermedia link.

What is hypermedia?

Hypermedia is a concept we’re all familiar with in one form or another. It was hypermedia that revolutionized the internet when Tim Berners-Lee created the World Wide Web. Other protocols existed for serving and finding documents (Gopher, Archive, FTP, and others), but the concept of ...