Struct actix_router::Router
source · [−]pub struct Router<T, U = ()> { /* private fields */ }
Expand description
Resource router.
It matches a routing resource to an ordered list of routes. Each is defined by a
single ResourceDef
and contains two types of custom data:
- The route value, of the generic type
T
. - Some context data, of the generic type
U
, which is only provided to the check function inrecognize_fn
. This parameter defaults to()
and can be omitted if not required.
Implementations
Constructs new RouterBuilder
with empty route list.
Finds the value in the router that matches a given routing resource.
The match result, including the captured dynamic segments, in the resource
.
pub fn recognize_mut<R>(
&mut self,
resource: &mut R
) -> Option<(&mut T, ResourceId)> where
R: Resource,
pub fn recognize_mut<R>(
&mut self,
resource: &mut R
) -> Option<(&mut T, ResourceId)> where
R: Resource,
Same as recognize
but returns a mutable reference to the matched value.
Finds the value in the router that matches a given routing resource and passes an additional predicate check using context data.
Similar to recognize
. However, before accepting the route as matched,
the check
closure is executed, passing the resource and each route’s context data. If the
closure returns true then the match result is stored into resource
and a reference to
the matched value is returned.
Same as recognize_fn
but returns a mutable reference to the matched
value.