gotham/router/route/matcher/
any.rs

1//! Defines the type `AnyRouteMatcher`
2
3use crate::router::non_match::RouteNonMatch;
4use crate::router::route::RouteMatcher;
5use crate::state::State;
6
7/// Matches any request without restriction (i.e. will accept any request which has already matched
8/// the path to the current route). For example, this matcher is used when delegating a path prefix
9/// to another router.
10///
11/// # Examples
12///
13/// ```rust
14/// # fn main() {
15/// #   use gotham::state::State;
16/// #   use gotham::router::route::matcher::{AnyRouteMatcher, RouteMatcher};
17/// #
18/// #   State::with_new(|state| {
19/// #
20/// let matcher = AnyRouteMatcher::new();
21///
22/// assert!(matcher.is_match(&state).is_ok());
23/// #
24/// #   });
25/// # }
26/// ```
27#[derive(Clone)]
28pub struct AnyRouteMatcher {}
29
30impl AnyRouteMatcher {
31    /// Creates a new `AnyRouteMatcher`
32    pub fn new() -> Self {
33        AnyRouteMatcher {}
34    }
35}
36
37impl RouteMatcher for AnyRouteMatcher {
38    fn is_match(&self, _state: &State) -> Result<(), RouteNonMatch> {
39        Ok(())
40    }
41}