pub struct Router { /* private fields */ }Expand description
Matchit-based router.
Implementations§
Source§impl Router
impl Router
pub fn new() -> Router
Sourcepub fn path_exists(&self, path: &str) -> bool
pub fn path_exists(&self, path: &str) -> bool
Check if a path is registered for any HTTP method.
Sourcepub fn allowed_methods(&self, path: &str) -> Vec<&'static str>
pub fn allowed_methods(&self, path: &str) -> Vec<&'static str>
The methods registered for path, for Allow headers and OPTIONS.
HEAD is included when GET is registered because the router serves
HEAD through the GET route (RFC 9110 §9.3.2). The list is empty when the
path is unknown.
Trait Implementations§
Source§impl IRouter for Router
impl IRouter for Router
Source§fn register(
&mut self,
method: HttpMethod,
path: &str,
endpoint: Arc<dyn IEndpoint>,
)
fn register( &mut self, method: HttpMethod, path: &str, endpoint: Arc<dyn IEndpoint>, )
Register a new route with the router.
Source§fn match_route<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut dyn IHttpContext,
) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<dyn IEndpoint>, HashMap<String, String>, String)>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Router: 'async_trait,
fn match_route<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 mut dyn IHttpContext,
) -> Pin<Box<dyn Future<Output = Result<Option<(Arc<dyn IEndpoint>, HashMap<String, String>, String)>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Router: 'async_trait,
Match an incoming request to a registered endpoint. Read more
Auto Trait Implementations§
impl !Freeze for Router
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Forget 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