pub struct Extension<T>(pub T);Expand description
Extension extractor
Retrieves typed data from request extensions that was inserted by middleware.
§Example
ⓘ
use rustapi_core::extract::Extension;
// Middleware inserts user data
#[derive(Clone)]
struct CurrentUser { id: i64 }
async fn handler(Extension(user): Extension<CurrentUser>) -> impl IntoResponse {
format!("User ID: {}", user.id)
}Tuple Fields§
§0: TTrait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Extension<T>where
T: Freeze,
impl<T> RefUnwindSafe for Extension<T>where
T: RefUnwindSafe,
impl<T> Send for Extension<T>where
T: Send,
impl<T> Sync for Extension<T>where
T: Sync,
impl<T> Unpin for Extension<T>where
T: Unpin,
impl<T> UnwindSafe for Extension<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