To show the features of the various frameworks in this book and how they solve problems in a different manner, we'll define a simple API, which we'll implement with the REST frameworks. For this book, we'll implement a simple to-do list API.
We want to create a RESTful API, so the most important part is to start with the description of the resources that can be managed through this API. For this API, we define the following resources:
Entity |
Description |
---|---|
Task |
A task is something that needs to be done. The JSON for a task looks similar to this: { "id": long, "title": string, "content": string, "notes": [noteList], "status": Status, "assignedTo": Person, } |
Project |
A project will allow us to group tasks together, and by assigning persons to a project, we can determine who can work on a specific task: { "id": string, "title": string, "tasks": [task], "members": [person], "updated": datetime } |
Person |
A person is someone who can work on a task and when done, close the task. A person can only work on those tasks to which he is assigned, or when he is part of the project to which a task belongs: { "id": string, "name": string } |
Note |
Notes can be added to tasks to provide additional information on how the task should be performed: { "id": string, "text": string, } |
Without going into too much detail here, we want to support approximately the following functionality in our API:
CRUD functionality: We want to support some basic CRUD operations. It should be possible to perform the following actions:
Advanced functions: Besides the standard CRUD-like functionality, we also want to provide some more advanced features:
Assign a task to a specific project
Assign a person to a task
Assign a person to a project
Move a task from one project to another
Note that we won't implement all the functionality for each framework. We'll mainly use this API to explain how we can use the various REST frameworks.