
Explore building fast, safe web APIs with rust, rocket, and diesel to create a beginner-friendly backend with json endpoints and database access.
Install Visual Studio Code as your Rust editor, use rustup to install the Rust toolchain, cargo, clippy, and rust docs, and enable the Rust analyzer extension for code completion.
Create a cargo project, add rocket, implement a hello world get endpoint at /, mount routes, run with cargo run, and test with curl.
Learn to switch static text to a json value using Rust with serde and serde_json, enable Rocket's json support, and build endpoints that return json.
Expose a Rust-based database through a rest api by building five endpoints for rustaceans: list, view, create, update, and delete, using get, post, put, and delete with json payloads.
Implement rocket error catchers to return JSON for 404 not found, register a not_found catcher, and ensure proper content type application/json for client-friendly error handling.
Implement a basic auth guard for rocket API by parsing the authorization header, decoding base64 credentials, and guarding routes like get_rustaceans with a BasicAuth struct that returns 401 when missing.
What is Diesel and its CLI tool.
Specifying r2d2 and diesel dependencies along with rocket support.
Creating our first model and doing our first query
Connecting our create endpoint to the database
Implementing DB queries for the rest of our endpoints
Creating reusable database related functions with repositories.
Handling errors gracefully without panicking
We will make deploying easier by putting migrations in our binary
Configuring rocket for production and then compiling our binary for production.
Installing nginx and setting a reverse proxy which serves our rocket application. Securing our application with SSL.
Goodbye!
Rust is a systems programming language which you can use to write applications with high performance. It is amazingly refreshing with a very helpful compiler who is your mentor since the very beginning.
Cargo is not only a package manager but also a build tool, a documentation generator and a lot more, making your every day managing Rust apps really easy.
It is no wonder that for these reasons, plus many more, Rust was voted as StackOverflow’s most loved and desired programming language, eight years in a row.
You are a web developer who wants to use Rust and is looking for a resource to guide you through the currently available tools and the surrounding ecosystem.
Well, look no further! In this course we will experience how easy and straight forward creating a web application with Rust is. We will create routes, endpoints, set up authorization, handle databases and feed our clients with JSON. We will use tools such as the Rocket framework and the Diesel ORM. The authorization will be a simple Basic authorization.
In the end we will have a fully functioning CRUD REST API ready to serve clients asynchronously and blazingly fast. We will also deploy this application behind an nginx webserver which will also handle the SSL negotiation, making our app served in a secured way under HTTPS. (requires an existing webserver and domain)
Jump abroad!