PathParams

Attribute Macro PathParams 

#[PathParams]
Expand description

Derive (de)serialization logic for a type that is going to be used to extract path parameters.

This macro derives StructuralDeserialize, serde::Serialize and serde::Deserialize for the type that it is applied to.

Check out PathParams for more details on how to work with path parameters in Pavex. Check out StructuralDeserialize if you are curious about the rationale behind this macro.

ยงExample

use pavex::{get, request::path::PathParams};

// Define a route with a path parameter, `{home_id}`.
#[get(path = "/home/{home_id}")]
pub fn get_home(params: &PathParams<Home>) -> String {
   format!("The identifier for this home is: {}", params.0.home_id)
}

// The PathParams attribute macro derives the necessary (de)serialization traits.
#[PathParams]
pub struct Home {
    // The name of the field must match the name of the path parameter
    // used in the route definition.
    home_id: u32
}