If you look at the code for our ShoppingListController and our ItemController, you will see a lot of similarities between the two. The only difference is the type of class that is expected in the request. For example, in the show method of ItemController, it is expecting Item to be passed as a second argument and in ShoppingListController it is expecting an object of ShoppingList type. Using generics in Swift, we can create a BaseResourceController so that we can share the code between the two controllers. The following are the steps to do this refactoring:
- Create an empty new file called BaseResourceController.swift inside the Controllers folder.
- In there, import FluentProvider, as we will be referencing ...