---
title: Rocket - web development with Rust
timestamp: 2023-12-22T12:30:01
author: szabgab
published: true
description: Examples with the Rocket web framework for Rustlang
show_related: false
tags:
    - Rocket
    - web
todo:
    - Hello World! with Rocket, tests in a separate file.
    - Set `content-type` `text/html`
    - Accept dynamic pathes (path parameters)
    - Accept GET parameter
    - Accept POST parameter
    - Cookies
    - Deployment
---

[Rocket](https://rocket.rs/) 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](https://github.com/szabgab/rust.code-maven.com/) or by following the links above the files.

[Rocket on Crates](https://crates.io/crates/rocket).


* [Hello World! with Rocket](/rocket-hello-world) - `text/plain`
* [Hello World with tests in separate file](/rocket-hello-world-separating-tests) - `test`.
* [Hello World! in HTML](/rocket-hello-world-html) - `RawHtml`, `text/html`, `headers`, `get_one`.
* [Hello World with Tera Templates](/rocket-hello-world-tera-template) - `rocket_dyn_templates`, `Template`, `context!`, `render`, `attach`, `fairing`.
* [Echo using HTTP GET](/rocket-echo-get) = `GET`, `Template`, `header`.
* [Echo using HTTP POST - form handling](/rocket-echo-post) - `POST`, `Form`, `Template`, `header`, `body`, `ContentType::Form`, `Status::UnprocessableEntity`, `422`.
* [Single counter in a plain text file](/rocket-single-counter-in-text-file).
* [Multi-counter using cookies](/rocket-multi-counter-using-cookies) - `CookieJar`, `add`, `get`.
* [Multi counter using encrypted cookies](/rocket-multi-counter-using-encrypted-cookies) - `add_private`, `get_private`, `secret_key`,`Rocket.toml`, `private_cookie`.
* [Liniting issues with Rocket](/rocket-linting) - Clippy
* [Logging in a Rocket-based web application](/rocket-logging) - `log`, `debug!`, `info!`, `warn!`,  `error!`.
* [Access custom configuration in the routes](/rocket-access-custom-configuration) - `rocket::Config`, `figment`, `extract_inner`.
* [Get, set (add), delete cookies - pending cookies](/rocket-set-get-delete-cookies) - `get`, `add`, `delete`, `get_pending`, `CookieJar`.
* [Process Query String of a GET request](/rocket-query-string)
* [Early return from routes](/rocket-early-return)
* [404 page with static content](/rocket-404-page-with-static-content) - `404`, `content`, `RawHtml`, `routes!`, `catchers!`, `mount`, `register`, `include_str!`.
* [In memory hit counter using state](/rocket-in-memory-hit-counter-state) - `AtomicUsize`, `Ordering`, `State`, `manage`.

## My Videos

* [Web development in Rust using Rocket](/web-development-in-rust-using-rocket) an introduction.
* [Building a job board](/web-development-in-rust-using-rocket-building-a-job-board)

## Other Videos

* [Rust Rocket.rs Part 1 - Creating an API Endpoint in Rocket](https://www.youtube.com/watch?v=2vxvSMkm5Lg)
* [Rust Rocket.rs Part 2 - Making API Requests Inside Rocket Server](https://www.youtube.com/watch?v=Alyr-JN2pdQ)
* [Rust Rocket.rs Part 3 - JSON Manipulation](https://www.youtube.com/watch?v=FHlCVMhNdeU)
* [Rust Rocket.rs Part 4v2 - Caching Function Results Within Rocket Context](https://www.youtube.com/watch?v=AQ4YXEQEA4o)
* [Rust Rocket.rs Part 5 - Serding Structs and Organizing the Codebase](https://www.youtube.com/watch?v=F6r3GleRewU)

## Rocket-based Open Source projects

* The [Pastebin tutorial](https://rocket.rs/guide/v0.5/pastebin/#pastebin-tutorial)
* The list of [showcases](https://rocket.rs/guide/v0.5/faq/#showcase).


* [Linked List - A personal knowledge base](https://linkedlist.org/) - [source](https://github.com/wezm/pkb)
* [Dew Point weather Forecast](https://dewpoint.7bit.org/) - [source](https://github.com/wezm/dewpoint.7bit.org)
* [Quotes between friends using UI I designed in 2003](https://quotes.randome.net/) - [source](https://github.com/wezm/Quotes)
* [Tempfiles](https://tempfiles.ninja/) A simple file sharing service that encrypts files at rest and deletes them automatically after 24 hours. - [source](https://github.com/olback/tempfiles-rs)


* [CreatureBattleSimulator](https://github.com/MDH0/CreatureBattleSimulator/) Rocket + surrealDB

* A lichess clone of SHOBU powered by Rust. (in development) [source](https://github.com/Kapsyloffer/RUSTBU)

