10 Implementing REST services
This chapter covers
- Understanding REST services
- Implementing a REST endpoint
- Managing the data that the server sends to the client in the HTTP response
- Obtaining data from the client in the HTTP request body
- Managing exceptions at the endpoint level
In chapters 7 through 9, I mentioned representational state transfer (REST) services a few times concerning web applications. In this chapter, we extend the discussion on REST services, and you’ll learn that REST services are not only related to web apps.
REST services are one of the most often-encountered ways to implement communication between two apps. In a short sentence, REST implies offering access to functionality the server exposes through endpoints that a client can call.
You use REST services to establish the communication between a client and a server in a web app. But you can also use REST services to develop the communication between a mobile app and a backend or even two backend services (figure 10.1).
Figure 10.1 REST services are a communication method between two apps. Today you can find REST services used in many places. A web client app or mobile app may call its backend solution through REST endpoints, but even backend services might communicate using REST web service calls.
Because in many Spring apps today, you have chances to encounter and need to work on REST services, I consider this subject essential and a must-learn for every Spring developer.