Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 2 months 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 (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-31T14:36:43.000Z (9 months ago)
- Last Synced: 2024-05-18T06:40:25.279Z (8 months ago)
- Topics: actix, axum-server, restapi, rust, tokio, tokio-rs, warp
- Language: Rust
- Homepage:
- Size: 221 KB
- Stars: 28
- Watchers: 3
- 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 ...## Get started
```bash
export DATABASE_URL='dev.db'cargo install diesel_cli --no-default-features --features "postgres sqlite mysql"
diesel setup
diesel migration run# Insert sample users
cargo run --bin insert_users
```**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`**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
```