pub fn path_params<T: DeserializeOwned, B>(
req: &Request<B>,
) -> Result<T, ServeError>Expand description
Extract path parameters from the request and deserialize into type T.
Path parameters are decoded and matched by the router, then deserialized
via serde’s MapDeserializer. Returns 400 Bad Request if deserialization
fails (e.g., an unparseable segment for a numeric type) or if the request
lacks extracted path parameters.
§Example
ⓘ
use serde::Deserialize;
use mini_serve::path_params;
#[derive(Deserialize)]
struct ItemId {
id: u64,
}
let item = path_params::<ItemId, _>(req)?;
println!("Item ID: {}", item.id);