Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

lesto tutorial

This tutorial takes you from zero to a complete API, one concept at a time. Every chapter stands on its own: it has the full code, the command to try it, and what you will see in the interactive documentation. If you know FastAPI you will feel at home; if you don’t, you don’t need to.

Prerequisites: stable Rust (rustup), curl and a browser.

#ChapterWhat you learn
1First stepsCreate the project, the first route, automatic documentation
2Path parametersPath<T>, types, several parameters, what happens when the type doesn’t fit
3Query parametersQuery<T>, optionals, defaults, validation
4Request bodyJson<T>, deserialization and validation with garde
5Validationgarde rules, nested structures, custom rules
6ResponsesReturn types, status codes, Result, empty responses
7Error handlingHttpError, RFC 9457, documented errors
8State and dependenciesState<S>, Extension, custom extractors (lesto’s Depends)
9SecurityBearer, API keys, Basic, OAuth2, verifying tokens
10Bigger projectsModules, nest, tags, route order
11Middleware and axumtower layers, CORS, logging, dropping down to axum
12TestingTesting the API without opening a port
13Databasessqlx stores with the db feature: transactions, principals, permissions
14AWS LambdaThe same binary behind API Gateway with the lambda feature
15ObservabilityRequest and store spans, OpenTelemetry semantic conventions, OTLP
16MCPRoutes as tools, resources and prompts for AI agents, both protocol eras, authentication
AFrom FastAPI to lestoCorrespondence table
BCommon problemsCompile errors and how to fix them
CWhy axum and not actix-webThe reasons behind the choice of core
DLeaving lestoThe way out, step by step: nobody is locked in
EPerformanceWhat lesto costs per request and at build time

Every snippet in this tutorial is compiled and tested in examples/99-tutorial (cargo test -p tutorial), so the documentation cannot drift from the API. The other examples grow with the chapters: examples/01-hello (chapter 1), examples/02-notes (a complete CRUD API, chapter 13), examples/03-lambda (chapter 14), examples/05-routers (chapter 10).

To read this tutorial as a website (sidebar, search, dark theme): cargo install mdbook && mdbook serve docs --open.