pub struct RouteMatch {
pub path: Option<PathMatch>,
pub headers: Vec<HeaderMatch>,
pub query_params: Vec<QueryParamMatch>,
pub method: Option<Method>,
}Expand description
Defines the predicate used to match requests to a given action. Multiple
match types are ANDed together; the match will evaluate to true only if all
conditions are satisfied. For example, if a match specifies a path match
and two query_params matches, it will match only if the request’s path
matches and both of the query_params are matches.
The default RouteMatch functions like a path match on the empty prefix, which matches every request.
§Match Ordering
Route matches are Ordered to help break ties. While once a Route is constructed, rules are matched in-order, sorting matches and rules can be useful while constructing a Route in case there isn’t an obvious order matches should apply in. From highest-value to lowest value, routes are ordered by:
- “Exact” path match.
- “Prefix” path match with largest number of characters.
- Method match.
- Largest number of header matches.
- Largest number of query param matches.
Note that this means a route that matches on a path is greater than a route that only matches on headers. To get a natural sort order by precedence, you may want to reverse-sort a list of matches.
Fields§
§path: Option<PathMatch>Specifies a HTTP request path matcher.
headers: Vec<HeaderMatch>Specifies HTTP request header matchers. Multiple match values are ANDed together, meaning, a request must match all the specified headers.
query_params: Vec<QueryParamMatch>Specifies HTTP query parameter matchers. Multiple match values are ANDed together, meaning, a request must match all the specified query parameters.
method: Option<Method>Specifies HTTP method matcher. When specified, this route will be matched only if the request has the specified method.
Implementations§
Trait Implementations§
Source§impl Clone for RouteMatch
impl Clone for RouteMatch
Source§fn clone(&self) -> RouteMatch
fn clone(&self) -> RouteMatch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RouteMatch
impl Debug for RouteMatch
Source§impl Default for RouteMatch
impl Default for RouteMatch
Source§fn default() -> RouteMatch
fn default() -> 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>,
Source§impl Ord for RouteMatch
impl Ord for RouteMatch
Source§impl PartialEq for RouteMatch
impl PartialEq for RouteMatch
Source§impl PartialOrd for RouteMatch
impl PartialOrd for RouteMatch
Source§impl Serialize for RouteMatch
impl Serialize for RouteMatch
impl Eq for RouteMatch
impl StructuralPartialEq for RouteMatch
Auto Trait Implementations§
impl Freeze for RouteMatch
impl RefUnwindSafe for RouteMatch
impl Send for RouteMatch
impl Sync for RouteMatch
impl Unpin for RouteMatch
impl UnwindSafe for RouteMatch
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request