RESTful Controller

In most cases, we will be creating controllers that will be responsible for handling requests to create, read, update, or delete a resource. These kind of CRUD operations performed on a resource make the controller resourceful. Vapor has made it easy to create such controllers by simply inheriting from their resources controller class, making it easy and straightforward to implement. Let's implement these RESTful controllers for our ShoppingList and Item Model so we can create, read, update, and delete them in the database using the API request. To get started, we need to follow these steps:

  1. Create a new file in the Controllers folder. Add a new empty file called ItemController.swift and make sure App target is checked. ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.