Adding RESTful APIs
Now that we have projects set up for our microservices, let’s add some RESTful APIs to our three core microservices!
The final result of this and the remaining topics in this chapter can be found in the $BOOK_HOME/Chapter03/2-basic-rest-services
folder.
First, we will add two projects (api
and util
) that will contain code that is shared by the microservice projects, and then we will implement the RESTful APIs.
Adding an API and a util project
To add an api
project, we need to do the following:
- First, we will set up a separate Gradle project where we can place our API definitions. We will use Java interfaces in order to describe our RESTful APIs and model classes to describe the data that the API uses in its requests and responses. To describe what types of errors can be returned by the API, a number of exception classes are also defined. Describing a RESTful API in a Java interface instead of directly in the Java class is, to me...