Skip to main content

Router

Struct Router 

Source
pub struct Router<H> { /* private fields */ }
Expand description

Deterministic ordered segment router (zero external dependencies).

Implementations§

Source§

impl<H> Router<H>

Source

pub fn new() -> Self

Source

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.

Source

pub fn get( &mut self, pattern: &'static str, policy: AccessPolicy, handler: H, ) -> &mut Self

Source

pub fn post( &mut self, pattern: &'static str, policy: AccessPolicy, handler: H, ) -> &mut Self

Source

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.

Source

pub fn allowed_methods(&self, path: &str) -> Vec<Method>

Return all registered HTTP methods matching path (for OPTIONS / Allow).

Trait Implementations§

Source§

impl<H> Default for Router<H>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<H> Forget for Router<H>

§

impl<H> Freeze for Router<H>
where *const u8 is !null: Freeze, PhantomData<CompiledRoute<H>>: Freeze,

§

impl<H> Move for Router<H>

§

impl<H> RefUnwindSafe for Router<H>
where H: RefUnwindSafe,

§

impl<H> Send for Router<H>
where H: Send, RawVecInner: Send, &'static str: Send,

§

impl<H> Sync for Router<H>
where H: Sync, RawVecInner: Sync,

§

impl<H> Unpin for Router<H>
where H: Unpin, *const u8 is !null: Unpin, &'static str: Unpin,

§

impl<H> UnsafeUnpin for Router<H>
where *const u8 is !null: UnsafeUnpin, PhantomData<CompiledRoute<H>>: UnsafeUnpin,

§

impl<H> UnwindSafe for Router<H>
where RawVecInner: UnwindSafe, &'static str: UnwindSafe, H: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.