Skip to content

Szymongib/rust-api-warp-and-diesel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust web API with Warp and Diesel

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.

Run

Database

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

Application

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