Struct actix_web_lab::guard::Acceptable
source ยท pub struct Acceptable { /* private fields */ }
๐Deprecated since 0.19.0: Type has graduated to Actix Web.
Expand description
A guard that verifies that an Accept
header is present and it contains a compatible MIME type.
An exception is that matching */*
must be explicitly enabled because most browsers send this
as part of their Accept
header for almost every request.
ยงExamples
use actix_web::{web, HttpResponse};
use actix_web_lab::guard::Acceptable;
web::resource("/images")
.guard(Acceptable::new(mime::IMAGE_STAR))
.default_service(web::to(|| async {
HttpResponse::Ok().body("only called when images responses are acceptable")
}));
Implementationsยง
sourceยงimpl Acceptable
impl Acceptable
sourcepub fn new(mime: Mime) -> Self
pub fn new(mime: Mime) -> Self
Constructs new Acceptable
guard with the given mime
type/pattern.
sourcepub fn match_star_star(self) -> Self
pub fn match_star_star(self) -> Self
Allows */*
in the Accept
header to pass the guard check.
Trait Implementationsยง
sourceยงimpl Clone for Acceptable
impl Clone for Acceptable
sourceยงfn clone(&self) -> Acceptable
fn clone(&self) -> Acceptable
Returns a copy of the value. Read more
1.0.0 ยท sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceยงimpl Debug for Acceptable
impl Debug for Acceptable
sourceยงimpl Guard for Acceptable
impl Guard for Acceptable
sourceยงfn check(&self, ctx: &GuardContext<'_>) -> bool
fn check(&self, ctx: &GuardContext<'_>) -> bool
Returns true if predicate condition is met for a given request.
Auto Trait Implementationsยง
impl Freeze for Acceptable
impl RefUnwindSafe for Acceptable
impl Send for Acceptable
impl Sync for Acceptable
impl Unpin for Acceptable
impl UnwindSafe for Acceptable
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
sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
sourceยงunsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
๐ฌThis is a nightly-only experimental API. (
clone_to_uninit
)sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more