Skip to content

kavicastelo/rocket-rust-web-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rocket Rust Web Server with Diesel & PostgreSQL

This project is a web server built with Rocket, using Diesel for database management and PostgreSQL as the database.

Features

  • REST API built with Rocket
  • PostgreSQL integration via Diesel ORM
  • CRUD operations for database entities

Requirements

  • Rust & Cargo (latest stable version)
  • PostgreSQL installed and running
  • Diesel CLI
  • Windows (with workaround for Diesel issue) or Linux/MacOS

Setup

  1. Install Rust:

    Follow the instructions at Rust's official site.

  2. Install PostgreSQL:

    Download and install PostgreSQL from PostgreSQL's official site.

  3. Install Diesel CLI:

    Install the Diesel CLI with the following command:

    cargo install diesel_cli --no-default-features --features postgres
  4. Set Up PostgreSQL Database:

    • Ensure PostgreSQL is running.
    • Create a database.
    createdb rocket_server
    • Update your rocket.toml file with the database URL:
    [global.databases]
    postgres_db = { url = "postgres://postgres:yourpassword@localhost/rocket_server" }
  5. Setup Environment (Windows only workaround): If running on Windows, [follow this solution](diesel-rs/diesel#2947 (comment).

  6. Run Migrations: Create the Diesel migrations:

    diesel migration run
  7. Run the Server: Run the Rocket server with:

    $env:ROCKET_LOG="debug"; cargo run # for Windows
    ROCKET_LOG=debug cargo run         # for Linux/MacOS
  8. Access the server: The server will be available at http://localhost:8000.

Troubleshooting

  • If you're facing issues on Windows with Diesel, it’s a known problem. You may try running the project inside WSL or a Linux VM for better compatibility.

License

This project is licensed under the MIT license.

About

This project is a web server built with Rocket, using Diesel for database management and PostgreSQL as the database.

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors