10 Implementing REST services

 

This chapter covers

  • Understanding REST services
  • Implementing REST endpoints
  • 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 they are not just related to web apps.

REST services are one of the most often encountered ways to implement communication between two apps. REST offers access to functionality the server exposes through endpoints 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 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.
CH10_F01_Spilca2

Because in many Spring apps today you have chances to encounter and work on REST services, I consider this subject a must-learn for every Spring developer.

10.1 Using REST services to exchange data between apps

10.2 Implementing a REST endpoint

10.3 Managing the HTTP response

10.3.1 Sending objects as a response body

10.3.2 Setting the response status and headers

10.3.3 Managing exceptions at the endpoint level

10.4 Using a request body to get data from the client

Summary

sitemap