10 Implementing REST services
This chapter covers
- 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
Up to this point, we have discussed representational state transfer (REST) services a few times concerning web applications. It’s time to extend the discussion on REST services, and you’ll learn they are not just related to web apps. REST is an essential subject and something I recommend you pay attention to.
In practice, today, you’ll likely generate a lot of REST services using several AI tools. However, you’ll always need to check the correctness of what AI generates for you, as mistakes in the shapes of requests and responses may not only lead to functional issues, but also security vulnerabilities.
10.1 Using REST services to exchange data between apps
REST services are one of the most often encountered ways to implement communication between two apps. REST offers access to functionality that the server exposes through endpoints that a client can call.
You use REST services to establish communication between a client and a server in a web app. But you can also use REST services to develop communication between a mobile app and a backend or even two backend services, as seen in Figure 10.1.