warp
project: on github- also on docs.rs
todos.rs
example https://github.com/seanmonstar/warp/blob/master/examples/todos.rs
After starting the example (cargo run --example todos
) following are some handy curl commands
curl -v -H 'content-type: application/json' -f http://localhost:3030/todos \
--data '{"id":4, "text":"trojka", "completed": false}'
returns 201
curl -X PUT -H 'content-type: application/json' -f http://localhost:3030/todos/4 \
--data '{"id":4, "text":"ctytka", "completed": false}'
curl http://localhost:3030/todos
returns 200
with json:
[
{
"id": 1,
"text": "hello",
"completed": false
},
{
"id": 2,
"text": "hello",
"completed": false
},
{
"id": 3,
"text": "trojka",
"completed": false
},
{
"id": 4,
"text": "ctyrka",
"completed": false
}
]
curl -X DELETE -f http://localhost:3030/todos/2 -H 'authorization: Bearer admin'
returns 204