This is an API developed with Rust, Rocket & Diesel and was created in order to study Rust. Therefore, the code might not be one of the best since I'm still a noob :D.
2 - Install diesel
if you haven't yet:
cargo install diesel_cli --no-default-features --features postgres
3 - Run the container:
docker compose up
4 - Create the tables:
diesel migration run
5 - Run the app:
cargo run
Posting a new content.
POST: http://localhost:8000/post
Body example:
{
"title": "My First Post",
"body": "The awesome body of my first post! :D"
}
Fetching posts.
GET: http://localhost:8000/posts
If you face the Id: library not found for -lpq
. Access this site to get to know how to fix it.
diesel setup
: Initializes the migrations setup for diesel
diesel migration generate posts
: Generates posts migration table
diesel migration run
: Runs migration codes
diesel migration redo
: It's going to execute the down.sql and up.sql file again in order to redo the migration.