[go: up one dir, main page]

Struct Router

Source
pub struct Router<D = ()> { /* private fields */ }
Expand description

The Router’s job is it to hold routes and to resolve them later against concrete URLs. The router is also a regular middleware and needs to be added to the middleware stack with server.utilize(router).

Implementations§

Source§

impl<D> Router<D>

Source

pub fn new() -> Router<D>

Source

pub fn match_route<'mw>( &'mw self, method: &Method, path: &str, ) -> Option<RouteResult<'mw, D>>

Trait Implementations§

Source§

impl<D> HttpRouter<D> for Router<D>

Source§

fn add_route<M: Into<Matcher>, H: Middleware<D>>( &mut self, method: Method, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specified method. A handler can be anything implementing the RequestHandler trait. Read more
Source§

fn get<M: Into<Matcher>, H: Middleware<D>>( &mut self, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specific GET request. Handlers are assigned to paths and paths are allowed to contain variables and wildcards. Read more
Source§

fn post<M: Into<Matcher>, H: Middleware<D>>( &mut self, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specific POST request. Read more
Source§

fn put<M: Into<Matcher>, H: Middleware<D>>( &mut self, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specific PUT request. Read more
Source§

fn delete<M: Into<Matcher>, H: Middleware<D>>( &mut self, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specific DELETE request. Read more
Source§

fn options<M: Into<Matcher>, H: Middleware<D>>( &mut self, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specific OPTIONS request. Read more
Source§

fn patch<M: Into<Matcher>, H: Middleware<D>>( &mut self, matcher: M, handler: H, ) -> &mut Self

Registers a handler to be used for a specific PATCH request. Read more
Source§

impl<D: 'static> Middleware<D> for Router<D>

Source§

fn invoke<'mw, 'conn>( &'mw self, req: &mut Request<'mw, 'conn, D>, res: Response<'mw, D>, ) -> MiddlewareResult<'mw, D>

Auto Trait Implementations§

§

impl<D> Freeze for Router<D>

§

impl<D = ()> !RefUnwindSafe for Router<D>

§

impl<D> Send for Router<D>

§

impl<D> Sync for Router<D>

§

impl<D> Unpin for Router<D>

§

impl<D = ()> !UnwindSafe for Router<D>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<T> UnsafeAny for T
where T: Any,