Skip to content

dexwritescode/todoservice

Repository files navigation

todoservice

CI

RESTful Rust Todo service

Running

Start Postgres DB

docker-compose --profile infra up -d

Run the SQL migration

diesel migration run

Run todoservice

cargo run --release

Run the tests

cargo test

Start Jaeger all-in-one docker container

docker-compose --profile tracing up -d

Open Jaeger UI on http://localhost:16686/

jaeger

REST API

Create Todo

Request

curl --location 'http://localhost:8080/todo' \
--header 'Content-Type: application/json' \
--data '{
    "title":"title text",
    "body":"body text"
}'

Response

200 OK

{
    "id": 1,
    "title": "title text",
    "body": "body text",
    "completed": false
}

Get Todo

Request

curl --location 'http://localhost:8080/todo/1'

Response

200 OK

{
    "id": 1,
    "title": "title text",
    "body": "body text",
    "completed": false
}

Delete Todo

Request

curl --location --request DELETE 'http://localhost:8080/todo/1'

Response

200 OK - (Empty response body)

Get All Todos

Request

curl --location 'http://localhost:8080/todo'

Response

200 OK

[
    {
        "id": 1,
        "title": "title text",
        "body": "body text",
        "completed": false
    },
    {
        "id": 2,
        "title": "a todo",
        "body": "a todo",
        "completed": true
    },
    {
        "id": 3,
        "title": "Clean out your car",
        "body": "busywork",
        "completed": true
    }
]

Create Random Todo

Request

curl --location --request POST 'http://localhost:8080/todo/random'

Response

200 OK

{
    "id": 3,
    "title": "Clean out your car",
    "body": "busywork",
    "completed": false
}

Mark Todo Completed

Request

curl --location --request PUT 'http://localhost:8080/todo/3'

Response

200 OK

{
    "id": 3,
    "title": "Clean out your car",
    "body": "busywork",
    "completed": true
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repo by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.