Code Explainers
Axum code explainers
rust
use axum::{extract::Multipart, http::StatusCode, Json}; use serde::Serialize; use tokio::io::AsyncWriteExt; use uuid::Uuid;
Streaming multipart uploads in Axum
multipart
streaming
async-io
Intermediate
10 steps
rust
use axum::{ extract::ws::{Message, WebSocket, WebSocketUpgrade}, response::IntoResponse, };
How an Axum WebSocket echo server works
websockets
async streams
protocol handling
Intermediate
8 steps
rust
use axum::{ extract::{Path, State}, http::StatusCode, response::{IntoResponse, Response},
Typed error handling in an Axum handler
error-handling
extractors
validation
Intermediate
9 steps
rust
use axum::{ body::Bytes, extract::State, http::{HeaderMap, StatusCode},
Verifying Stripe webhook signatures in Axum
hmac
webhooks
constant-time-comparison
Intermediate
8 steps
rust
use axum::{ body::Body, extract::Request, http::{header, StatusCode},
How bearer-auth middleware works in Axum
middleware
authentication
request extensions
Intermediate
7 steps
rust
use axum::{ http::StatusCode, response::IntoResponse, routing::get,
Serving an SPA and API with Axum
routing
static-files
spa-fallback
Intermediate
7 steps
rust
use axum::{ extract::{Path, State}, http::StatusCode, routing::get,
Building a JSON user API in Axum
routing
shared-state
json-serialization
Intermediate
8 steps
rust
use std::time::Duration; use axum::{ http::{header, HeaderValue, Method},
Configuring CORS on an Axum Router
cors
middleware
http-headers
Intermediate
7 steps
rust
use axum::{ body::Bytes, extract::State, http::StatusCode,
Handling raw byte uploads in Axum
extractors
shared-state
request-limits
Intermediate
7 steps
rust
use axum::{ extract::{Query, State}, http::StatusCode, Json,
Paginated, filtered product listing in Axum
pagination
query-parameters
sql-filtering
Intermediate
8 steps
rust
use axum::{ extract::FromRef, http::StatusCode, response::{IntoResponse, Redirect},
Signed cookie sessions in Axum
sessions
cookies
authentication
Intermediate
8 steps
rust
use axum::{ http::StatusCode, response::{IntoResponse, Response}, Json,
How a custom error type maps to HTTP in Axum
error-handling
enums
trait-implementation
Intermediate
7 steps
rust
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; use serde::{Deserialize, Serialize}; use uuid::Uuid;
Building a typed create_user handler in Axum
serde
extractors
sqlx
Intermediate
7 steps
rust
use axum::{ response::sse::{Event, KeepAlive, Sse}, routing::get, Router,
Streaming live price ticks with SSE in Axum
server-sent-events
broadcast-channel
streaming
Advanced
8 steps
rust
use std::net::SocketAddr; use std::time::Duration; use axum::{routing::get, Json, Router};
Per-IP rate limiting in Axum with tower-governor
rate-limiting
middleware
tower
Intermediate
7 steps
rust
use axum::{ body::Body, extract::Request, http::{header::HeaderValue, HeaderName},
Request ID middleware in Axum
middleware
tracing
request-extensions
Intermediate
7 steps
rust
use std::time::Duration; use axum::{routing::get, Router}; use tokio::net::TcpListener;
Graceful shutdown in an Axum server
graceful-shutdown
signal-handling
async
Intermediate
8 steps
rust
use axum::{ extract::{Path, State}, routing::{get, post}, Json, Router,
Building a nested REST API router in Axum
routing
extractors
shared-state
Intermediate
8 steps