September 2019
Intermediate to advanced
668 pages
15h 59m
English
The util project will be packaged as a library in the same way as the api project. The source code for the util project is available at $BOOK_HOME/Chapter03/2-basic-rest-services/util. The project contains the following Java files:
Except for the code in ServiceUtil.java, these classes are reusable utility classes that we can use to map Java exceptions to proper HTTP status codes, as described in the Adding error handling section. The main purpose of ServiceUtil.java is to find out the hostname, IP address, and port used by the microservice. The class exposes a method,