Java

  • Published on
    When it comes to REST API, a controller is a component that controls the flow of the data both from the user and the application itself. In other words, controllers accept an HTTP request and pass the request to the services of the application and return the output from the services to the user. This is why a controller is one of the most important components of the application. In this part 2, we are going to set up a controller and create a REST API with a basic CRUD process.
  • Published on
    In the previous chapter, we set up a controller and made 5 endpoints to do CRUD operations. The API works very fine, but if you consider the maintainability and extendability of the code base, writing all business logic in controllers is a bad practice because it violates the responsibility of a controller and the controller has too many other responsibilities. This is why we will introduce a service layer to this project to remove all business logic from the controller and put them into the service layer.