Several cogs and mechanical elements in purple.

Workshop: 3 days, on-site or remote

Build production-ready API services in Rust

Workshop description

Book this workshop

Our mentors look forward to working with your team and unlocking new capabilities.
Get in touch

1

Hello Axum!

Axum is the web framework we will be using throughout the workshop. We'll go over its architecture and where it fits in the broader Rust ecosystem.

2

Your first endpoint

We'll learn enough about Axum to write an API with a single endpoint that returns a static "Hello World" response. It'll be an opportunity to learn about the key components of an Axum application (the HTTP server, the router, the handler) and how to connect them together. We'll also wire up our first integration test. No matter how simple the endpoint, we want to make sure it works!

3

Extracting data from the request

We'll expand our API with new endpoints that leverage route parameters, query parameters and JSON bodies. It'll be your introduction to the `FromRequest` trait and how to use it to write extractors, the key mechanism to inject data from the incoming request into your handlers.

4

Telemetry

At this point, the API is starting to get complex and you're likely to run into issues: how do you debug them? We'll learn how to use the `tracing` and the `tower-http` crates to instrument our code and capture structured logs. It'll be the first middleware you'll mount in your application.

5

Shared application state

Some data outlives the lifetime of a single request—e.g. a database connection pool, or a cache client. We'll learn how to model this data as the state of our application and how to access it from our handlers.

6

Hierarchical configuration

As soon as you start doing something non-trivial, you'll need to configure your application with parameters that are specific to the environment it's running in. We'll learn how to use the `config` crate to load configuration from environment variables and configuration files, using a layered approach.

7

External state, working with databases

We'll learn how to use the `sqlx` crate to connect to a PostgreSQL database and execute queries. We'll cover connection pooling and transactions, as well as how to test endpoints that interact with the database.

8

External state, working with third-party APIs

We'll learn how to use the `reqwest` crate to call third-party APIs. We'll cover connection management, retries and timeouts, as well as how to test endpoints that interact with third-party services via `wiremock`.

9

Sharing logic between endpoints via middlewares

When you have multiple endpoints, you'll often find yourself repeating the same logic in each of them. We'll learn how to extract this logic into middlewares and mount them in our application.

10

Preparing to deploy

Most platforms require you to package your application as a Docker image for deployment. We'll cover how to write a Dockerfile to package our API, with a focus on effective caching (via `cargo-chef`) and techniques to minimise the size of the final image.

Your mentor

Luca Palmieri

Principal Engineering Consultant

Luca Palmieri builds technology products for a living. His current focus is on backend development, software architecture and the Rust programming language. He is the author of "Zero to Production in Rust".

Not the right workshop for you?

Take a look at our wide range of workshops to take your team to the next level
Our workshops

Stay up to date on Rust

Subscribe to our newsletter and stay up to date about the latest events, workshops, and other news around Rust.

Book this workshop

Our mentors look forward to working with your team and unlocking new capabilities.
Get in touch