pub struct RouteMatch {
pub host: Option<String>,
pub path: Option<String>,
pub path_type: PathMatchType,
pub headers: HashMap<String, String>,
pub methods: Option<Vec<String>>,
}Expand description
Route matching criteria.
Fields§
§host: Option<String>Host pattern (supports wildcards)
path: Option<String>Path pattern
path_type: PathMatchTypePath matching type
headers: HashMap<String, String>Headers to match
methods: Option<Vec<String>>HTTP methods to match
Implementations§
Source§impl RouteMatch
impl RouteMatch
Sourcepub fn matches(
&self,
host: &str,
path: &str,
method: &str,
headers: &HeaderMap,
) -> bool
pub fn matches( &self, host: &str, path: &str, method: &str, headers: &HeaderMap, ) -> bool
Whether a request matches these criteria.
Every field that is set has to match; a field left unset matches anything. That is the only reading under which adding a criterion can never widen a route.
path_type, methods and headers were all declarable and all ignored
before this existed – the route filter compared host and path prefix and
nothing else. Each of those silent no-ops widened a route past what its
author wrote: path_type = "exact" on /health also matched
/health-internal, and a route restricted to methods = ["GET"]
accepted DELETE.
Trait Implementations§
Source§impl Clone for RouteMatch
impl Clone for RouteMatch
Source§impl Debug for RouteMatch
impl Debug for RouteMatch
Source§impl Default for RouteMatch
impl Default for RouteMatch
Source§impl<'de> Deserialize<'de> for RouteMatch
impl<'de> Deserialize<'de> for RouteMatch
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RouteMatch
impl RefUnwindSafe for RouteMatch
impl Send for RouteMatch
impl Sync for RouteMatch
impl Unpin for RouteMatch
impl UnsafeUnpin for RouteMatch
impl UnwindSafe for RouteMatch
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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