Simple web API written in Rust with Warp as a web framework and Diesel for database connection.
This is the repository for the blog post.
The application needs a running Postgres database. Use local Postgres or run it in a Docker container:
docker run -p 5432:5432 --rm -e POSTGRES_PASSWORD=password postgres:12
When the database is running make sure its connection string matches the one in .env
file.
Use Diesel CLI to setup database and run migrations:
diesel database setup
Before starting the application set DATABASE_URL
environment variable. If the database connection string matches the one in .env
file, run:
export $(cat .env | xargs)
Run application with cargo
:
cargo run