Rocket is one of the web development frameworks for the Rust programming language. It has a nice web site that comes with a nice tutorial, but for me, to undertand it I needed my own, stand-alone examples. On this page you'll find the list of examples. You can get the full source code of each one of them from Rust Maven GitHub repo or by following the links above the files.
- Hello World! with Rocket -
text/plain
- Hello World with tests in separate file -
test
. - Hello World! in HTML -
RawHtml
,text/html
,headers
,get_one
. - Hello World with Tera Templates -
rocket_dyn_templates
,Template
,context!
,render
,attach
,fairing
. - Echo using HTTP GET =
GET
,Template
,header
. - Echo using HTTP POST - form handling -
POST
,Form
,Template
,header
,body
,ContentType::Form
,Status::UnprocessableEntity
,422
. - Single counter in a plain text file.
- Multi-counter using cookies -
CookieJar
,add
,get
. - Multi counter using encrypted cookies -
add_private
,get_private
,secret_key
,Rocket.toml
,private_cookie
. - Liniting issues with Rocket - Clippy
- Logging in a Rocket-based web application -
log
,debug!
,info!
,warn!
,error!
. - Access custom configuration in the routes -
rocket::Config
,figment
,extract_inner
. - Get, set (add), delete cookies - pending cookies -
get
,add
,delete
,get_pending
,CookieJar
. - Process Query String of a GET request
- Early return from routes
- 404 page with static content -
404
,content
,RawHtml
,routes!
,catchers!
,mount
,register
,include_str!
. - In memory hit counter using state -
AtomicUsize
,Ordering
,State
,manage
.
My Videos
- Web development in Rust using Rocket an introduction.
- Building a job board
Other Videos
- Rust Rocket.rs Part 1 - Creating an API Endpoint in Rocket
- Rust Rocket.rs Part 2 - Making API Requests Inside Rocket Server
- Rust Rocket.rs Part 3 - JSON Manipulation
- Rust Rocket.rs Part 4v2 - Caching Function Results Within Rocket Context
- Rust Rocket.rs Part 5 - Serding Structs and Organizing the Codebase
Rocket-based Open Source projects
-
The list of showcases.
-
Tempfiles A simple file sharing service that encrypts files at rest and deletes them automatically after 24 hours. - source
-
CreatureBattleSimulator Rocket + surrealDB
-
A lichess clone of SHOBU powered by Rust. (in development) source