1- install Rust
curl https://sh.rustup.rs -sSf | sh -s -- -y
2- insrall sqlx
cargo install sqlx-cli
1- create database table
sqlx database create
2- run migration
sqlx mig run
cargo run
docker-compose up -d
POST http://localhost:8080/devices
{ "brand": "example-brand", "name": "example-name", "power": 1, "serial": "example-serial" }
{
"id: 1,
"brand": "example-brand",
"name": "example-name",
"power": 1,
"serial": "example-serial"
}
GET http://localhost:8080/devices
[
{
"id: 1,
"brand": "example-brand",
"name": "example-name",
"power": 1,
"serial": "example-serial"
}
]
GET http://localhost:8080/devices/{device_id}
{
"id: 1,
"brand": "example-brand",
"name": "example-name",
"power": 1,
"serial": "example-serial"
}
DELETE http://localhost:8080/devices/{device_id}
status 200
PUT http://localhost:8080/devices/{device_id}
{ "brand": "new-example-brand", "name": "new-example-name", "power": 5, "serial": "new-example-serial" }
{
"id": 1,
"brand": "new-example-brand",
"name": "new-example-name",
"power": 5,
"serial": "new-example-serial"
}