Struct gotham::router::route::matcher::AndRouteMatcher [−][src]
pub struct AndRouteMatcher<T, U> where
T: RouteMatcher,
U: RouteMatcher, { /* fields omitted */ }
Expand description
Allows multiple RouteMatcher
values to be combined when accessing a request.
Examples
let methods = vec![Method::GET, Method::HEAD];
let supported_media_types = vec![mime::APPLICATION_JSON];
let method_matcher = MethodOnlyRouteMatcher::new(methods);
let accept_matcher = AcceptHeaderRouteMatcher::new(supported_media_types);
let matcher = AndRouteMatcher::new(method_matcher, accept_matcher);
state.put(Method::GET);
// Request that matches both requirements
let mut headers = HeaderMap::new();
headers.insert(ACCEPT, mime::APPLICATION_JSON.to_string().parse().unwrap());
state.put(headers);
assert!(matcher.is_match(&state).is_ok());
// Request that fails method requirements
state.put(Method::POST);
assert!(matcher.is_match(&state).is_err());
// Request that fails accept header
state.put(Method::GET);
let mut headers = HeaderMap::new();
headers.insert(ACCEPT, mime::TEXT.to_string().parse().unwrap());
state.put(headers);
assert!(matcher.is_match(&state).is_err());
Implementations
Trait Implementations
impl<T: Clone, U: Clone> Clone for AndRouteMatcher<T, U> where
T: RouteMatcher,
U: RouteMatcher,
impl<T: Clone, U: Clone> Clone for AndRouteMatcher<T, U> where
T: RouteMatcher,
U: RouteMatcher,
Auto Trait Implementations
impl<T, U> RefUnwindSafe for AndRouteMatcher<T, U>
impl<T, U> Send for AndRouteMatcher<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for AndRouteMatcher<T, U> where
T: Sync,
U: Sync,
impl<T, U> Unpin for AndRouteMatcher<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for AndRouteMatcher<T, U> where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = M
type Output = M
The concrete RouteMatcher each implementation will provide.
Transform into a RouteMatcher
of the the associated type identified by Output
.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more