This project is an experimental CRUD (Create, Read, Update, Delete) API written in Rust. The purpose of this project is to explore building a simple New Post CRUD application in Rust, using the popular Actix web framework and Diesel ORM. Mostly for learning purpose
Some highlighted improvements for this experiment:
- Docker multi-stage build for rust using cargo-chef => enable the last layer to only contain one needed binary file and faster build time.
- Leverage Diesel migration to migrate database at compile time => enable ship a single executable file.
To run this project, you will need the docker and docker compose:
docker compose up -d
Open http://localhost:8000 (or {docker ip}:8000 on windows) to view it in the browser.
The API provides endpoints for basic CRUD operations on a sample entity called Post. Each item has an id, title, body and published.
Endpoint: POST /post
Request Body: JSON object with title, body and optional published fields.
Endpoint: GET /count-post
Endpoint: GET /post/:id
Endpoint: PATCH /post/:id
Endpoint: DELETE /post/:id