Struct actix_web::guard::GuardContext
source · pub struct GuardContext<'a> { /* private fields */ }
Expand description
Provides access to request parts that are useful during routing.
Implementations§
source§impl<'a> GuardContext<'a>
impl<'a> GuardContext<'a>
sourcepub fn head(&self) -> &RequestHead
pub fn head(&self) -> &RequestHead
Returns reference to the request head.
sourcepub fn req_data(&self) -> Ref<'a, Extensions>
pub fn req_data(&self) -> Ref<'a, Extensions>
Returns reference to the request-local data/extensions container.
sourcepub fn req_data_mut(&self) -> RefMut<'a, Extensions>
pub fn req_data_mut(&self) -> RefMut<'a, Extensions>
Returns mutable reference to the request-local data/extensions container.
sourcepub fn header<H: Header>(&self) -> Option<H>
pub fn header<H: Header>(&self) -> Option<H>
Extracts a typed header from the request.
Returns None
if parsing H
fails.
§Examples
use actix_web::{guard::fn_guard, http::header};
let image_accept_guard = fn_guard(|ctx| {
match ctx.header::<header::Accept>() {
Some(hdr) => hdr.preference() == "image/*",
None => false,
}
});
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for GuardContext<'a>
impl<'a> !RefUnwindSafe for GuardContext<'a>
impl<'a> !Send for GuardContext<'a>
impl<'a> !Sync for GuardContext<'a>
impl<'a> Unpin for GuardContext<'a>
impl<'a> !UnwindSafe for GuardContext<'a>
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