Learn about the intent of Spring Data REST and the concept of hypermedia-driven APIs.
- [Instructor] In this chapter, we will learn about Spring Data REST which is a service for creating Hypermedia driven RESTful APIs. So what is a Hypermedia driven RESTful API? According to Roy Fielding, who first published the REST API Specification, an API is not truly RESTful unless it follows a uniform interface. One of his constraints for a uniform interface is followed when Hypermedia As an Engine of Application State, or HATEOAS, is employed.
A RESTful API should do more than expose resource endpoints over HTTP. It should also expose the API's documentation and automatically provide navigation between resources. Hypermedia driven APIs accomplish just that. The implementers of Spring Data REST agreed, and that's why Spring Data REST APIs are Hypermedia driven out of the box. No extra configuration is needed. In fact, you have already seen it in action.
Remember back in chapter one when we tested to see if our microservice was running properly? We invoked localhost:8080 and it generated the JSON packet. This is an example of that out of the box support. Localhost:8080/profile is an active length to the documentation the API's exposed by the microservice. Spring Data REST employs the Hypermedia Application Language, or HAL standard, to associate resource objects to one another.
Later in this chapter, we will describe how Hypermedia is used to associate resources to each other but first let's start creating APIs to expose the Explore California Tours and Tour Packages.
- Setting up the project
- Building, deploying, and launch the microservice
- Declaring Spring Data JPA repository interfaces
- Invoking repositories
- Using Spring Data query methods
- Exposing RESTful APIs with Spring Data REST
- Using the /search resource to invoke query methods
- Paging and sorting
- Declaring a new REST controller
- Creating HTTP methods for creating, reading, updating and deleting persistent data.