pub struct Path<T>(pub T);Expand description
Extract path parameters from the request URL
§Example
use torch_web::extractors::Path;
// Extract a single parameter
async fn get_user(Path(user_id): Path<u32>) {
// user_id is automatically parsed from the URL
}
// Extract multiple parameters as a tuple
async fn get_post(Path((user_id, post_id)): Path<(u32, u32)>) {
// Extracts from "/users/:user_id/posts/:post_id"
}
// Extract into a custom struct
#[derive(serde::Deserialize)]
struct PostPath {
user_id: u32,
post_id: u32,
}
async fn get_post_struct(Path(path): Path<PostPath>) {
// Automatically deserializes path parameters
}Tuple Fields§
§0: TTrait Implementations§
Source§impl<T> FromRequestParts for Path<T>where
T: DeserializeFromPath,
impl<T> FromRequestParts for Path<T>where
T: DeserializeFromPath,
Auto Trait Implementations§
impl<T> Freeze for Path<T>where
T: Freeze,
impl<T> RefUnwindSafe for Path<T>where
T: RefUnwindSafe,
impl<T> Send for Path<T>where
T: Send,
impl<T> Sync for Path<T>where
T: Sync,
impl<T> Unpin for Path<T>where
T: Unpin,
impl<T> UnwindSafe for Path<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more