Skip to content

Clean Architecture Implementation, async-io high performance Rest API in Rust

Notifications You must be signed in to change notification settings

hienduyph/rust-webapi

Repository files navigation

Backend Implementation in Rust with Clean Architect

  • Clean Architect
  • Independent framework: I've tried actix-web, warp, ...
  • Independent database: Support MySQL, PostgresSQL ...

Get started

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: cargo run --bin axum
  • warp: cargo run --bin warp
  • actix-web: cargo run --bin actix

Check the server's running

curl http://127.0.0.1:8000/
curl http://127.0.0.1:8000/health

Login

# required jq installed.
export TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"email": "hienduyph@gmail.com", "password": "admin"}' http://127.0.0.1:8000/auth/login | jq -r '.token')

Users

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

About

Clean Architecture Implementation, async-io high performance Rest API in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages