pub struct RequestContext { /* private fields */ }Expand description
Mutable request state passed through extraction and handler dispatch.
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn set_route_metadata(&mut self, metadata: RouteMetadata)
pub fn set_route_metadata(&mut self, metadata: RouteMetadata)
Attaches route metadata for interceptor and handler access.
Sourcepub fn route_metadata(&self) -> Option<&RouteMetadata>
pub fn route_metadata(&self) -> Option<&RouteMetadata>
Returns the route metadata attached to the current request, if any.
Sourcepub const fn request_mut(&mut self) -> &mut Request
pub const fn request_mut(&mut self) -> &mut Request
Returns mutable access to the transport-neutral request.
Sourcepub fn insert_extension<T: Clone + Send + Sync + 'static>(
&mut self,
value: T,
) -> Option<T>
pub fn insert_extension<T: Clone + Send + Sync + 'static>( &mut self, value: T, ) -> Option<T>
Inserts typed request-scoped state and returns the previous value, if any.
Sourcepub fn extension<T: Clone + Send + Sync + 'static>(&self) -> Option<&T>
pub fn extension<T: Clone + Send + Sync + 'static>(&self) -> Option<&T>
Returns typed request-scoped state.
Sourcepub fn preferred_content_type(&self) -> Option<&str>
pub fn preferred_content_type(&self) -> Option<&str>
Returns the client’s preferred content type from the Accept header.
Parses the header and returns the highest-weighted MIME type, or None
if the header is absent.
Sourcepub fn accepts_json(&self) -> bool
pub fn accepts_json(&self) -> bool
Returns true if the client prefers JSON responses.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RequestContext
impl !RefUnwindSafe for RequestContext
impl !UnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnsafeUnpin for RequestContext
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