Updated Jun 23, 2026

Rocket From Zero

Rocket is the Rust web framework that prizes ergonomics above all. Where axum and actix-web ask you to assemble routers and handlers, Rocket lets you write #[get("/books/<id>")] above a function and be done — the framework reads your attributes and function signature and wires everything up. It leans hard on Rust macros to do that, which is the trade: the code is wonderfully concise and readable (close to what a Flask or Express developer expects), at the cost of more "magic" happening behind the attributes. If you've found other Rust frameworks verbose, Rocket is the antidote.

The mental model is "attributes describe routes, the function signature describes inputs." A handler is a function annotated with #[get(...)]/#[post(...)]; its parameters are pulled from the path, query, body, and request guards (types that must succeed for the handler to run, like an authenticated user); and its return type is a Responder. You register handlers with routes![...] and start with #[launch]. Shared dependencies are managed state, and fairings are Rocket's middleware. Hold "the attribute is the route, the signature is the request," and Rocket's magic becomes legible.

📝 This teaches the framework — it assumes you know Rust (ownership, traits, Result, and a comfort with how attribute macros feel — Rust From Zero). Compare it with axum and actix-web to see the macros-vs-builders split; all three sit on async Rust (Tokio). Rocket compiles and runs as a Rust program, so examples are shown with the commands to run them.

How to read this

Read in order — it grows one service (a small books API) from a single attribute route to a tested, configured REST API. Phases carry difficulty badges.

The phases

Part 1 — The core (🟢 Basic)

  1. What Rocket Is & Your First Server 🟢 — #[get], routes!, #[launch], and a running server.
  2. Routing & Dynamic Paths 🟢 — path segments <id>, query params, and FromParam.
  3. Request Guards & Data 🟡 — Json<T> data, forms, and request guards (the auth pattern).

Part 2 — A real API (🟡 → 🔴) 4. Responders 🟡 — Json, status, custom responders, and returning Result. 5. Managed State & Fairings 🔴 — State<T>, .manage(...), and fairings as middleware. 6. A REST API with Error Catchers 🔴 — full CRUD plus #[catch(404)] error catchers.

Part 3 — Ship it (🟡 → 🟢) 7. Testing & Configuration 🟡 — the local test client and Rocket.toml. 8. Where to Go Next 🟢 — Rocket vs axum/actix, data layers, and what to build.

The throughline: an attribute is the route, the function signature is the request (params + guards), the return type is the response, and macros wire it together. Concise Rust web code, with the magic now explained.


Phase 1: What Rocket Is & Your First Server →