actix-web From Zero
actix-web is one of the oldest, fastest, and most battle-tested web frameworks in Rust - it sits at or
near the top of the TechEmpower benchmarks year after year, and a lot of production Rust runs on it. Where
axum is the newer, tower-native option, actix-web is the mature, feature-packed
one: routing, extractors, middleware, websockets, and more, all included. The name carries a bit of
history - it grew out of an actor framework - but day to day you write plain async fn handlers and rarely
touch actors at all.
The mental model is three pieces. An App holds your routes and shared state; an HttpServer
runs one or more copies of that App across worker threads; and a handler is an async fn whose
arguments are extractors (Path, Query, Json, web::Data) and whose return value is a
Responder. If that sounds like axum, it is - the big Rust frameworks converged on "extract from the
request, return something that becomes a response." The differences are in the details, and this guide
walks them.
📝 This teaches the framework - it assumes you know Rust (ownership, traits,
Result,async/await- Rust From Zero). It's most useful read alongside axum (the closest comparison) and on top of Tokio. actix-web 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 articles API) from a single route to a tested, deployable REST API. Phases carry difficulty badges.
The phases
Part 1 - The core (🟢 Basic)
- What actix-web Is & Your First Server 🟢 -
App,HttpServer, the async handler, and a running server. - Routing & Extractors 🟢 - methods, scopes,
Path/Query/Json, and how extractors work. - Responders 🟡 -
HttpResponse,impl Responder, returning JSON and status codes.
Part 2 - A real API (🟡 → 🔴)
4. Shared State with web::Data 🟡 - web::Data<T>, app_data, and sharing a pool across workers.
5. Middleware 🔴 - wrap, the built-in Logger, from_fn, and writing your own.
6. A REST API with Error Handling 🔴 - full CRUD plus the ResponseError trait for clean error responses.
Part 3 - Ship it (🟡 → 🟢)
7. Testing & Production 🟡 - actix_web::test, workers, and deployment.
8. Where to Go Next 🟢 - actix-web vs axum/Rocket, data layers, and what to build.
The throughline: an
Appof routes, run by anHttpServer, with handlers that extract from the request and return aResponder. Mature, fast, and more familiar than its actor heritage suggests.