pub struct Router<H> { /* private fields */ }Expand description
Deterministic ordered segment router (zero external dependencies).
Implementations§
Source§impl<H> Router<H>
impl<H> Router<H>
pub fn new() -> Self
Sourcepub fn add(
&mut self,
method: Method,
pattern: &'static str,
policy: AccessPolicy,
handler: H,
) -> &mut Self
pub fn add( &mut self, method: Method, pattern: &'static str, policy: AccessPolicy, handler: H, ) -> &mut Self
Register a route with explicit HTTP method, pattern, and access policy.
pub fn get( &mut self, pattern: &'static str, policy: AccessPolicy, handler: H, ) -> &mut Self
pub fn post( &mut self, pattern: &'static str, policy: AccessPolicy, handler: H, ) -> &mut Self
Sourcepub fn match_request(&self, method_str: &str, path: &str) -> RouteMatch<'_, H>
pub fn match_request(&self, method_str: &str, path: &str) -> RouteMatch<'_, H>
Match an incoming HTTP method and path. Static/exact matches declared earlier win.
Per RFC 9110 §9.3.2, HEAD matches GET routes.
Sourcepub fn allowed_methods(&self, path: &str) -> Vec<Method>
pub fn allowed_methods(&self, path: &str) -> Vec<Method>
Return all registered HTTP methods matching path (for OPTIONS / Allow).
Trait Implementations§
Auto Trait Implementations§
impl<H> Forget for Router<H>
impl<H> Freeze for Router<H>
impl<H> Move for Router<H>
impl<H> RefUnwindSafe for Router<H>where
H: RefUnwindSafe,
impl<H> Send for Router<H>
impl<H> Sync for Router<H>
impl<H> Unpin for Router<H>
impl<H> UnsafeUnpin for Router<H>
impl<H> UnwindSafe for Router<H>
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