pub struct Router { /* private fields */ }
Expand description
Router struct is used for route request to different handlers.
Implementations
sourceimpl Router
impl Router
sourcepub fn routers(&self) -> &Vec<Router, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn routers(&self) -> &Vec<Router, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get current router’s children reference.
sourcepub fn routers_mut(&mut self) -> &mut Vec<Router, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn routers_mut(&mut self) -> &mut Vec<Router, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get current router’s children mutable reference.
sourcepub fn hoops(&self) -> &Vec<Arc<dyn Handler + 'static>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn hoops(&self) -> &Vec<Arc<dyn Handler + 'static>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get current router’s middlewares reference.
sourcepub fn hoops_mut(&mut self) -> &mut Vec<Arc<dyn Handler + 'static>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn hoops_mut(&mut self) -> &mut Vec<Arc<dyn Handler + 'static>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get current router’s middlewares mutable reference.
sourcepub fn filters(&self) -> &Vec<Box<dyn Filter + 'static, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn filters(&self) -> &Vec<Box<dyn Filter + 'static, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get current router’s filters reference.
sourcepub fn filters_mut(
&mut self
) -> &mut Vec<Box<dyn Filter + 'static, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn filters_mut(
&mut self
) -> &mut Vec<Box<dyn Filter + 'static, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get current router’s filters mutable reference.
sourcepub fn detect(
&self,
req: &mut Request,
path_state: &mut PathState
) -> Option<DetectMatched>
pub fn detect(
&self,
req: &mut Request,
path_state: &mut PathState
) -> Option<DetectMatched>
Detect current router is matched for current request.
sourcepub fn append(self, others: Vec<Router, Global>) -> Router
pub fn append(self, others: Vec<Router, Global>) -> Router
Append all routers in a Vec as children of current router.
sourcepub fn with_hoop<H>(handler: H) -> Router where
H: Handler,
pub fn with_hoop<H>(handler: H) -> Router where
H: Handler,
Add a handler as middleware, it will run the handler in current router or it’s descendants handle the request.
sourcepub fn hoop<H>(self, handler: H) -> Router where
H: Handler,
pub fn hoop<H>(self, handler: H) -> Router where
H: Handler,
Add a handler as middleware, it will run the handler in current router or it’s descendants handle the request.
sourcepub fn filter_fn<T>(self, func: T) -> Router where
T: 'static + Fn(&mut Request, &mut PathState) -> bool + Send + Sync,
pub fn filter_fn<T>(self, func: T) -> Router where
T: 'static + Fn(&mut Request, &mut PathState) -> bool + Send + Sync,
Create a new FnFilter from Fn.
sourcepub fn then<F>(self, func: F) -> Router where
F: FnOnce(Router) -> Router,
pub fn then<F>(self, func: F) -> Router where
F: FnOnce(Router) -> Router,
When you want write router chain, this function will be useful, You can write your custom logic in FnOnce.
sourcepub fn get<H>(self, handler: H) -> Router where
H: Handler,
pub fn get<H>(self, handler: H) -> Router where
H: Handler,
Create a new child router with MethodFilter to filter get method and set this child router’s handler.
sourcepub fn post<H>(self, handler: H) -> Router where
H: Handler,
pub fn post<H>(self, handler: H) -> Router where
H: Handler,
Create a new child router with MethodFilter to filter post method and set this child router’s handler.
sourcepub fn put<H>(self, handler: H) -> Router where
H: Handler,
pub fn put<H>(self, handler: H) -> Router where
H: Handler,
Create a new child router with MethodFilter to filter put method and set this child router’s handler.
sourcepub fn delete<H>(self, handler: H) -> Router where
H: Handler,
pub fn delete<H>(self, handler: H) -> Router where
H: Handler,
Create a new child router with MethodFilter to filter delete method and set this child router’s handler.
sourcepub fn patch<H>(self, handler: H) -> Router where
H: Handler,
pub fn patch<H>(self, handler: H) -> Router where
H: Handler,
Create a new child router with MethodFilter to filter patch method and set this child router’s handler.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more