Controllers are the logical parts of a Vapor application. A controller converts input to an output. We just defined the I/O models as well as the database models, so we have everything we need to write the controllers.
We have already created the two controller files needed. Now, let's work through each one of them, as follows:
- Writing CategoriesController: This controller will manage the categories.
- Writing ProductsController: This controller will manage the products.
We will start with CategoriesController.