This project aims to speed up the development of a web backend written in Rust using Rocket + Diesel, with the more common needs addressed. Both the Web Framework and ORM chosen are the most popular at the time of this implementation.
- This sample code uses SQLite as database backend however Diesel also supports MySQL and PostgreSQL;
- Using this project as starting point absolutely not exempt you of reading all of the material that you can before start coding using Rust;
- VSCode is the suggested code editor and its launch configuration is included. You just need to install the extensions Rust + CodeLLDB from the Marketplace;
- Because of Rocket, you need to use the nightly version of Rust using
rustup default nightly
; - In case of you need to debug you code using VSCode is highly recomended that you install Rust source code using the command
rustup component add rust-src
and make sure of setting "sourceMap" of .vscode/launch.json to map the original source location to the output of$(rustc --print sysroot)/lib/rustlib/src/rust
. See the CodeLLDB manual;
- Assuming that Rust is installed in your system, follow the note 4 above;
- Install Diesel CLI with
cargo install diesel_cli
; - Define an environment variable DATABASE_URL pointing to a file to be created (our SQLite database);
- Call
diesel migration run
; - Call
cargo run
and open in your browser the URL shown at the console.