curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
nano ~/.cargo/config
[source.crates-io]
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
sudo docker run -d
--name song-db
-p 5432:5432
-v determined_db:/var/lib/postgresql/data
-e POSTGRES_DB=determined
-e POSTGRES_PASSWORD=sunlf
postgres:10
$ cargo install sqlx-cli
sqlx migrate run
sqlx migrate add card
名称 | 类型 | 说明 |
---|---|---|
id | i32 | 唯一编号 |
content | String | 长度1024,存储错误文件内容 |
device_id | i32 | 医疗设备编号 |
time | datetime | 记录创建时间 |
git clone https://github.com/minikiller/song-project
cd song-project
cargo build --release
cargo run --release
POST http://150.158.141.195:3000/bodys HTTP/1.1
content-type: application/json
{
"id":101,
"device_id":5,
"content": "sample"
}
GET http://150.158.141.195:3000/bodys HTTP/1.1
PATCH http://localhost:3000/bodys/2 HTTP/1.1
content-type: application/json
{
"id":3,
"device_id":2,
"content": "sample123456"
}
DELETE http://localhost:3000/bodys/1 HTTP/1.1
POST http://150.158.141.195:3000/authorize HTTP/1.1
content-type: application/json
{
"client_id": "foo",
"client_secret": "bar"
}
返回信息如下:
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiaGVsbG8iLCJzdWIiOiJiQGIuY29tIiwiY29tcGFueSI6IkFDTUUiLCJleHAiOjIwMDAwMDAwMDB9.HlvHZEu5dTXyzna6UxH4nAwW8YumZdZSq9t_Mdz3h3A",
"token_type": "Bearer"
GET http://localhost:3000/protected
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiaGVsbG8iLCJzdWIiOiJiQGIuY29tIiwiY29tcGFueSI6IkFDTUUiLCJleHAiOjIwMDAwMDAwMDB9.HlvHZEu5dTXyzna6UxH4nAwW8YumZdZSq9t_Mdz3h3A
修改.env 文件,调整如下内容,就可以控制日志的显示级别:
RUST_LOG=song_project=debug,tower_http=debug,sqlx=info