https://github.com/hienduyph/rust-webapi
Clean Architecture Implementation, async-io high performance Rest API in Rust
https://github.com/hienduyph/rust-webapi
actix axum-server restapi rust tokio tokio-rs warp
Last synced: about 1 month ago
JSON representation
Clean Architecture Implementation, async-io high performance Rest API in Rust
- Host: GitHub
- URL: https://github.com/hienduyph/rust-webapi
- Owner: hienduyph
- Created: 2020-03-07T15:03:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-22T04:07:28.000Z (6 months ago)
- Last Synced: 2025-03-31T02:04:47.358Z (2 months ago)
- Topics: actix, axum-server, restapi, rust, tokio, tokio-rs, warp
- Language: Rust
- Homepage:
- Size: 265 KB
- Stars: 32
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Backend Implementation in Rust with Clean Architect
- Clean Architect
- Independent framework: I've tried actix-web, warp, ...
- Independent database: Support MySQL, PostgresSQL ...## Run the services
```bash
docker compose up -d
```Setup Migrations
```bash
export DATABASE_URL=postgres://postgres:[email protected]:5432/mydbcargo install diesel_cli --no-default-features --features "postgres sqlite mysql"
diesel setup
diesel migration run# Insert sample users
cargo run --bin insert_users
```**Check the server's running**
```bash
curl http://127.0.0.1:8000/
curl http://127.0.0.1:8000/health
```**Login**
```bash
# required jq installed.
export TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"email": "[email protected]", "password": "admin"}' http://127.0.0.1:8000/auth/login | jq -r '.token')
```**Users**
```bash
curl -s -H "Authorization: bearer $TOKEN" http://127.0.0.1:8000/users
curl -s -H "Authorization: bearer $TOKEN" http://127.0.0.1:8000/users/1802d2f8-1a18-43c1-9c58-1c3f7100c842
```## Dev Started
**Run the server**- [axum](./src/apps/axum): `cargo run --bin axum`
- [warp](./src/apps/warp): `cargo run --bin warp`
- [actix-web](./src/apps/actix): `cargo run --bin actix`