0PricingLogin
Learn Rust Coding · Lesson

Extractors

Parse requests.

What is an extractor?

An extractor is a handler parameter that pulls a piece of the request out for you. Axum inspects the parameter types and fills them in.

  • No manual request parsing
  • Type-driven and composable

Path extractor

Path captures dynamic URL segments. The type inside determines how the segment is parsed.

use axum::extract::Path;

async fn user(Path(id): Path<u32>) -> String {
    format!("user {}", id)
}

All lessons in this course

  1. Axum Routing
  2. Extractors
  3. JSON and State
  4. Middleware
← Back to Learn Rust Coding