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.
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 more