pub struct Router { /* private fields */ }Expand description
HTTP method routing
Implementations§
Source§impl Router
impl Router
pub fn new() -> Self
pub fn insert( &mut self, method: &str, path: &str, handler: DynHandler, ) -> Result<()>
Sourcepub fn allowed_methods(&self, path: &str) -> Vec<&'static str>
pub fn allowed_methods(&self, path: &str) -> Vec<&'static str>
Methods with a route for path, in a fixed order, including the
implicit HEAD (next to GET) and OPTIONS. Empty when the path is unknown.
pub fn match_route( &self, method: &str, path: &str, ) -> Result<(DynHandler, Params)>
Sourcepub fn match_route_with_pattern(
&self,
method: &str,
path: &str,
) -> Result<(DynHandler, Params, Arc<str>)>
pub fn match_route_with_pattern( &self, method: &str, path: &str, ) -> Result<(DynHandler, Params, Arc<str>)>
Like Router::match_route, also returning the pattern the route was
registered under (/users/{id}), a low-cardinality name for the route
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Router
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin 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