Enhancing the controller with a service and HATEOAS
In Chapter 3, API Specifications and Implementation, we created the Controller
class for the Cart API – CartController
, which just implements the Swagger Codegen-generated API specification interface – CartApi
. It was just a mere block of code without any business logic or data persistence calls.
Now, since we have written the repositories, services, and HATEOAS assemblers, we can enhance the API controller class as shown here:
@RestController public class CartsController implements CartApi { private static final Logger log = LoggerFactory .getLogger(CartsController.class); private CartService service; private final CartRepresentationModelAssembler assembler; public CartsController(CartService service...