pub struct RuleSet<R> { /* private fields */ }
Expand description
A set of rules applicable to certain paths.
See the note at Self::empty
on how paths are matched.
Implementations§
source§impl RuleSet<AllowList>
impl RuleSet<AllowList>
sourcepub fn check_origin(
&self,
origin: &Uri,
uri_path: &str,
) -> Option<(MethodAllowList<'_>, &[HeaderName], Duration)>
pub fn check_origin( &self, origin: &Uri, uri_path: &str, ) -> Option<(MethodAllowList<'_>, &[HeaderName], Duration)>
Check if the (cross-origin) request’s origin
Uri
is allowed by the CORS rules.
See CorsAllowList::check
for info about the return types.
sourcepub fn check_cors_request<T>(
&self,
request: &Request<T>,
) -> Option<(MethodAllowList<'_>, &[HeaderName], Duration)>
pub fn check_cors_request<T>( &self, request: &Request<T>, ) -> Option<(MethodAllowList<'_>, &[HeaderName], Duration)>
Check if the Request::headers
and Request::uri
is allowed with this ruleset.
This will not check for errors in
access-control-request-headers
.
Use this over Self::check_origin
because this checks for same_origin
requests.
See CorsAllowList::check
for info about the return types.
source§impl<R> RuleSet<R>
impl<R> RuleSet<R>
sourcepub fn add(self, path: impl AsRef<str>, rule: impl Into<R>) -> Self
pub fn add(self, path: impl AsRef<str>, rule: impl Into<R>) -> Self
Adds rule
to path
.
To use this with Host::vary
, use Self::add_mut
, which this uses internally.
By default, path
will only match requests with the exact path.
This can be changed by appending *
to the end of the path, which
will then check if the request path start with path
.
sourcepub fn add_mut(
&mut self,
path: impl AsRef<str>,
rule: impl Into<R>,
) -> &mut Self
pub fn add_mut( &mut self, path: impl AsRef<str>, rule: impl Into<R>, ) -> &mut Self
Same as Self::add
but operating on a mutable reference.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for RuleSet<R>
impl<R> RefUnwindSafe for RuleSet<R>where
R: RefUnwindSafe,
impl<R> Send for RuleSet<R>where
R: Send,
impl<R> Sync for RuleSet<R>where
R: Sync,
impl<R> Unpin for RuleSet<R>where
R: Unpin,
impl<R> UnwindSafe for RuleSet<R>where
R: 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
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)
clone_to_uninit
)