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.
| # | Chapter | What you learn |
|---|---|---|
| 1 | First steps | Create the project, the first route, automatic documentation |
| 2 | Path parameters | Path<T>, types, several parameters, what happens when the type doesn’t fit |
| 3 | Query parameters | Query<T>, optionals, defaults, validation |
| 4 | Request body | Json<T>, deserialization and validation with garde |
| 5 | Validation | garde rules, nested structures, custom rules |
| 6 | Responses | Return types, status codes, Result, empty responses |
| 7 | Error handling | HttpError, RFC 9457, documented errors |
| 8 | State and dependencies | State<S>, Extension, custom extractors (lesto’s Depends) |
| 9 | Security | Bearer, API keys, Basic, OAuth2, verifying tokens |
| 10 | Bigger projects | Modules, nest, tags, route order |
| 11 | Middleware and axum | tower layers, CORS, logging, dropping down to axum |
| 12 | Testing | Testing the API without opening a port |
| 13 | Databases | sqlx stores with the db feature: transactions, principals, permissions |
| 14 | AWS Lambda | The same binary behind API Gateway with the lambda feature |
| 15 | Observability | Request and store spans, OpenTelemetry semantic conventions, OTLP |
| 16 | MCP | Routes as tools, resources and prompts for AI agents, both protocol eras, authentication |
| A | From FastAPI to lesto | Correspondence table |
| B | Common problems | Compile errors and how to fix them |
| C | Why axum and not actix-web | The reasons behind the choice of core |
| D | Leaving lesto | The way out, step by step: nobody is locked in |
| E | Performance | What 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.