A todo list app built with Axum. It serves as an introduction to backend development in rust. It is based on the todo example from axum's examples.
Run the following command to get started:
git clone https://github.com/EteimZ/axum-todo.git
cd axum-todo
cargo run
The application has the following endpoints.
POST
/todos: This endpoint creates a new todo.GET
/todos: This endpoint gets all of todos in the server.GET
/todos/:id: This endpoint gets a particular todo.PATCH
/todos/:id: This endpoint updates an existing todo.DELETE
/todos/:id: This endpoint deletes a particular todo.
Using curl client we can make requests to the running application.
curl -X POST \
-H "Content-Type: application/json" \
-d '{"text": "Buy groceries"}' \
http://127.0.0.1:3000/todos
Response:
{"id":"0d98604c-237f-4ae6-b9a4-d6eecdee5020",
"text":"Buy groceries",
"completed":false}
curl -X GET http://127.0.0.1:3000/todos
Response:
[
{
"id": "ec2553b0-6f91-4c48-a8b1-39bffc41b46a",
"text": "Complete axum todo.",
"completed": false
},
{
"id": "0d98604c-237f-4ae6-b9a4-d6eecdee5020",
"text": "Buy groceries",
"completed": false
}
]
curl -X GET http://127.0.0.1:3000/todos/ec2553b0-6f91-4c48-a8b1-39bffc41b46a
Response:
{
"id": "ec2553b0-6f91-4c48-a8b1-39bffc41b46a",
"text": "Complete axum todo",
"completed": false
}
curl -X PATCH \
-H "Content-Type: application/json"
-d '{ "completed": true}'
http://127.0.0.1:3000/todos/ec2553b0-6f91-4c48-a8b1-39bffc41b46a
Response:
{
"id": "ec2553b0-6f91-4c48-a8b1-39bffc41b46a",
"text": "Complete axum todo",
"completed": true
}
curl -X DELETE http://127.0.0.1:3000/todos/ec2553b0-6f91-4c48-a8b1-39bffc41b46a