A jwt template project of actix-web and sqlx
cargo install sqlx-cli --git https://github.com/launchbadge/sqlx
- Choose a database(
mysql
,postgres
,sqlite
). - Sets the default feature as the database name on Cargo.toml(current is
mysql
). - Configure the databse you can see
sql/user.up.$database.sql
. - Run
cargo run -- -v
after update .env and template.json. - Test current api:
curl -v --data '{"name": "Bob", "email": "[email protected]", "password": "Bobpass"}' -H "Content-Type: application/json" -X POST localhost:8080/user/register
curl -v --data '{"name": "Bob", "email": "[email protected]", "password": "Bobpass"}' -H "Content-Type: application/json" -X POST localhost:8080/user/login
curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb2IiLCJleHAiOjE1OTEyNDYwOTR9.O1dbYu3tqiIi6I8OUlixLuj9dp-1tLl4mjmXZ0ve6uo' localhost:8080/user/userInfo
curl -v -X DELETE -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb2IiLCJleHAiOjE1OTEyNDYwOTR9.O1dbYu3tqiIi6I8OUlixLuj9dp-1tLl4mjmXZ0ve6uo' localhost:8080/user/delete/Bob
curl 'localhost:8080/user/userInfo?access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb2IiLCJleHAiOjE1OTEyNTYxNDd9.zJKlZOozYfq-xMXO89kjUyme6SA8_eziacqt5gvXj2U'
- Modify the code and write your own code, enjoy.
- The sqlx query macros needs to be connected to the database represented by DATABASE_URL in .env, or you can consider using the unchecked version instead.
- Use docker to start a Redis quickly
docker run --name redis-6379 --network host -d redis redis-server --port 6379 --bind 127.0.0.1 --appendonly no # --requirepass pw
# pip3 install iredis
# iredis/redis-cli -p 6379 # -a pw
- The Redis client crates, current is mobc.
- redis-rs: The most used Redis client.
- mobc: An asynchronous connection pool.
- deadpool: An asynchronous connection pool.
- actix-redis: Redis integration for actix framework base on redis-async-rs.
- bb8: An asynchronous connection pool provides the same configuration options as r2d2.
- r2d2: A synchronized connection pool, not recommended.
- redis-async-rs: Another Redis client.
- actix-web: https://github.com/actix/actix-web
- sqlx: https://github.com/launchbadge/sqlx
- actix documentation: https://actix.rs/docs/
- actix-web-jwt with mongodb: https://github.com/emreyalvac/actix-web-jwt
- actix-examples: https://github.com/actix/examples
- an instance: https://github.com/biluohc/KeepStats
- ormx: https://github.com/NyxCode/ormx
- sea-orm: https://github.com/SeaQL/sea-orm
- sea-query: https://github.com/SeaQL/sea-query
- Prisma Client Rust: https://github.com/Brendonovich/prisma-client-rust
- validator: https://docs.rs/validator
- axum: https://github.com/tokio-rs/axum