pub struct Router {
pub routes: Vec<Route>,
pub groups: Vec<RouteGroup>,
pub middleware: Vec<String>,
/* private fields */
}
Expand description
Router for managing routes
Fields§
§routes: Vec<Route>
All registered routes
groups: Vec<RouteGroup>
Route groups
middleware: Vec<String>
Global middleware
Implementations§
Source§impl Router
impl Router
Sourcepub fn group<F>(&mut self, prefix: &str, group_fn: F) -> &mut Selfwhere
F: FnOnce(&mut RouteGroup),
pub fn group<F>(&mut self, prefix: &str, group_fn: F) -> &mut Selfwhere
F: FnOnce(&mut RouteGroup),
Creates a route group
Sourcepub fn middleware(&mut self, middleware: Vec<String>) -> &mut Self
pub fn middleware(&mut self, middleware: Vec<String>) -> &mut Self
Adds global middleware
Sourcepub fn find_route(&self, name: &str) -> Option<&Route>
pub fn find_route(&self, name: &str) -> Option<&Route>
Finds a route by name
Sourcepub fn url(
&self,
name: &str,
params: Option<HashMap<String, String>>,
) -> Result<String>
pub fn url( &self, name: &str, params: Option<HashMap<String, String>>, ) -> Result<String>
Generates a URL for a named route
Sourcepub fn all_routes(&self) -> Vec<&Route>
pub fn all_routes(&self) -> Vec<&Route>
Gets all routes including group routes
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Gets route count
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Router
impl !RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
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
Mutably borrows from an owned value. Read more