Skip to content

Instantly share code, notes, and snippets.

@pkozelka
Last active April 4, 2021 20:27
Show Gist options
  • Save pkozelka/f4798f8d4ba62d11baaf6810ee2ce784 to your computer and use it in GitHub Desktop.
Save pkozelka/f4798f8d4ba62d11baaf6810ee2ce784 to your computer and use it in GitHub Desktop.
Notes for RUST warp, the todos example

WARP - how to try the todos example

After starting the example (cargo run --example todos) following are some handy curl commands

create

curl -v -H 'content-type: application/json' -f http://localhost:3030/todos \
    --data '{"id":4, "text":"trojka", "completed": false}'

returns 201

update

curl -X PUT -H 'content-type: application/json' -f http://localhost:3030/todos/4 \
    --data '{"id":4, "text":"ctytka", "completed": false}'

retrieve

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
    }
]

delete

curl -X DELETE -f http://localhost:3030/todos/2 -H 'authorization: Bearer admin' 

returns 204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment