Developing a RESTful API server with Actix Web, PostgreSQL and Diesel on Docker: I. API spec.

API spec.

Methods Endponts Functions
GET /todos Get the list of all todos.
POST /todos Create a todo.
GET /todos/{id} Get the details of the todo.
PATCH /todos/{id} Update the todo.
DELETE /todos/{id} Delete the todo.

GET /todos

Get the list of all todos.

Response

{
  "todos": [
    {
      "id": 1,
      "title": "象の散歩",
      "complete": false
    },
    {
      "id": 2,
      "title": "サボテンの水やり",
      "complete": true
    }
  ]
}

POST /todos

Create a todo.

Params

{
  "title": "エビの収穫"
}

Response

On success:

{
  "message": "Created successfully."
}

On failure:

{
  "message": "Creation failed: {reason}"
}

GET /todos/{id}

Response

On success:

{
  "id": 1,
  "title": "象の散歩",
  "complete": false
}

On failure:

{
  "message": "Todo with id {} does not exist."
}

PATCH /todos/{id}

Params

{
  "complete": true
}

Response

On success:

{
  "message": "Updated successfully."
}

On error:

{
  "message": "Update failed: {reason}"
}

DELETE /posts/{id}

Response

On success:

{
  "message": "Deleted successfully."
}

On error:

{
  "message": "Deletion failed: {reason}"
}