Search code examples
spring-mvcspring-hateoas

Spring HATEOAS integration example


I am looking to develop a Spring MVC Integration with HATEOAS. I've searched the web and I didn't find any such working example through which I can understand HATEOAS concept.

I only found this resource which itself has lots of code and is really difficult to understand. Is a complete working sample available?


Solution

  • You may have a look at this sample Spring/Boot HATEOAS project: https://github.com/opencredo/spring-hateoas-sample and some explanation in the related blog post: Implementing HAL hypermedia REST API using Spring HATEOAS

    The examples shows a simple but not-so-trivial API.

    The API represents a fictional library with a catalogue of books, related with authors and publishers.

    All Resources includes examples of links. Book GET also also shows how to return different level of details, either embedding or linking related resources.

    Beyond GET examples for all resources, it also includes other "command" endpoints, like for adding a book to the collection, borrowing and returning books.