Outline updated November 2026
Web APIs with Rust and Actix-web
Class Duration
21 hours of live training delivered over 3-5 days to accommodate your scheduling needs.
Student Prerequisites
- Working Rust experience equivalent to Rust Essentials
- Familiarity with HTTP and REST is helpful but not required
- Comfort with PostgreSQL or another SQL database is recommended
Target Audience
Back-end engineers who build HTTP services in Rust, from internal and public APIs to high-throughput services where garbage-collection pauses are a problem. New to Rust? Start with Rust Essentials.
Description
This course teaches engineers to build REST APIs in Rust with Actix-web. Students define routes, extractors, and handlers, then add WebSockets, streaming, and middleware for logging, sessions, and errors. They generate OpenAPI documentation, connect to PostgreSQL with sqlx, and add tracing. Later modules cover testing, containers, and deployment. Students also use AI coding assistants, with Cargo, clippy, and the compiler catching their mistakes.
Learning Outcomes
- Build a REST API in Rust with Actix-web.
- Define routes, extractors, and handlers idiomatically.
- Write middleware for logging, sessions, and authentication.
- Add WebSocket endpoints with
actix-ws. - Generate OpenAPI documentation with
utoipa. - Query PostgreSQL with compile-time-checked SQL in sqlx.
- Add structured logging and tracing with
tracing. - Test handlers and middleware against a real database.
- Containerize and deploy the service.
- Review AI-generated Rust with the compiler and clippy.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples.
Software Requirements
A free GitHub account, the current stable Rust toolchain via rustup (2024 edition), with examples on Actix-web 4, Visual Studio Code or another supported editor with the rust-analyzer extension, Docker for the local PostgreSQL instance, curl and/or HTTPie or Postman, and an AI coding assistant of choice (GitHub Copilot, Cursor, or Claude Code). A cloud-based environment can be provided if local installation is restricted.
Training Topics
REST and HTTP in Practice
- What REST is and isn't
- Methods, status codes, and headers
- URLs, query strings, and path parameters
- JSON, form, and multipart bodies
curl, HTTPie, and Postman
Actix-web Overview
- Actix-web versus Axum and Rocket
- Comparing Express, FastAPI, and ASP.NET Core
- Worker threads on Tokio
- Why handlers need not be
Send HttpServer,App, and application factories- Project layout and feature flags
- Running and debugging in VS Code
Routing
- Mapping routes to handlers
- Path parameters and query strings
- Method routing
- Resource trees and scopes
- Route configuration
- Versioning your API
Extractors
- The extractor model
Path,Query,Json,Form, andBytes- Shared state with
web::Data - Custom extractors
- Payload limits
Request Handlers
- The handler lifecycle
- The
Respondertrait - JSON, file, and binary responses
- Streaming responses
- Server-sent events
- WebSockets with
actix-ws
API Documentation
- OpenAPI from Rust types with
utoipa - Serving Swagger UI
- Documenting errors and security schemes
Middleware
- The middleware model
- Logging with
tracing-actix-web - Sessions with
actix-session - Cookie and Redis session backends
- Error types with
thiserror - The
ResponseErrortrait - Authentication and authorization
- Rate limiting
- CORS with
actix-cors - Custom middleware
Static Files and Assets
- Serving files with
actix-files - Asset bundling and content hashing
- Single-page-app fallback routing
Database with sqlx and PostgreSQL
- Connecting with sqlx
- Compile-time-checked queries
- Migrations with
sqlx-cli - Transactions and connection pooling
- Mapping rows to structs
Observability
- Structured logging with
tracing - OpenTelemetry exporters
- Metrics and health checks
- Production diagnostics
Testing
- Integration tests against PostgreSQL
- Unit tests with
actix_web::test - Snapshot tests and golden files
- Load testing with
ohaorwrk
Deployment
- Optimized release builds
- Multi-stage container builds
- Image hardening
- Hosting options
- Graceful shutdown
- Worker configuration
- Configuration with
dotenvy
AI-Assisted Actix-web Development
- AI coding tools for Rust
- Prompts for handlers and middleware
- Compiler, clippy, and tests as checks
- Outdated actor-based WebSocket suggestions
- Reviewing
unsafeandunwrap - Unbounded allocations
- AI-assisted refactors and review