Skip to content

Rust (Actix& Diesel)+ PostgreSQL starter pack. With enhance docker build and migration as binary file

Notifications You must be signed in to change notification settings

haicheviet/rust-actix-crud-app

Repository files navigation

Rust CRUD API Experiment

Overview

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.

Requirements

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.

API Endpoints

The API provides endpoints for basic CRUD operations on a sample entity called Post. Each item has an id, title, body and published.

Create an Item

Endpoint: POST /post
Request Body: JSON object with title, body and optional published fields.

Count all public Post

Endpoint: GET /count-post

Get a post by ID

Endpoint: GET /post/:id

Publish a post

Endpoint: PATCH /post/:id

Delete a post

Endpoint: DELETE /post/:id

About

Rust (Actix& Diesel)+ PostgreSQL starter pack. With enhance docker build and migration as binary file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published