Goodnessuc / rusting-actix-diesel

Here's a simple Rust API that leverages the Actix framework and the Diesel ORM. The goal was to make the process simple and intuitive for Go, Ruby and Python developers looking to build APIs in Rust to understand Resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› οΈ actix-diesel-rocket - Rust with Actix-web and Diesel

A simple API built using Rust's Actix-web framework and Diesel ORM for interacting with Human data.

πŸ“‘ Overview

The project demonstrates CRUD (Create, Read, Update, Delete) operations for a Human entity. The operations include:

  • Creating a new human.
  • Reading all humans from the database.
  • Updating an existing human's details.
  • Deleting a human.

🌟 Features

  • Built with the Actix-web framework for asynchronous web handling.
  • Uses Diesel ORM for database operations.
  • SQLite as the database.
  • Clean and clear route definitions.
  • Structured error handling.

🧰 Prerequisites

  • Rust and Cargo installed.
  • SQLite3

πŸš€ Setup & Run

  1. Clone the repository:
git clone https://github.com/Goodnessuc/rusting-actix-diesel.git
  1. Navigate to the project directory:
cd rusting-actix-diesel
  1. Run migrations to setup the database:
diesel migration run
  1. Start the server:
cargo run

The server will start at 127.0.0.1:8080.

πŸ“œ API Endpoints

πŸ§‘ Create a New Human

  • Method: POST
  • Endpoint: /human
  • Body:
{
  "first_name": "John",
  "last_name": "Doe",
  "age": 30
}

πŸ“– Read All Humans

  • Method: GET
  • Endpoint: /humans

✏️ Update a Human

  • Method: PUT
  • Endpoint: /human/{id}
  • Body:
{
  "first_name": "Jane",
  "last_name": "Doe",
  "age": 32
}

❌ Delete a Human

  • Method: DELETE
  • Endpoint: /human/{id}

🀝 Contribute

Feel free to fork the project, make some updates, and submit pull requests.

πŸ“„ License

This project is licensed under the MIT License.

About

Here's a simple Rust API that leverages the Actix framework and the Diesel ORM. The goal was to make the process simple and intuitive for Go, Ruby and Python developers looking to build APIs in Rust to understand Resources


Languages

Language:Rust 83.7%Language:Dockerfile 16.3%