Struct salvo_core::routing::Router
source · [−]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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn routers(&self) -> &Vec<Router>ⓘ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>ⓘ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>ⓘ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>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn hoops(&self) -> &Vec<Arc<dyn Handler>>ⓘ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>>ⓘ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>>ⓘ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>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn filters(&self) -> &Vec<Box<dyn Filter>>ⓘ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>>ⓘ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>>ⓘ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>) -> Self
pub fn append(self, others: Vec<Router>) -> Self
Append all routers in a Vec as children of current router.
sourcepub fn with_hoop<H: Handler>(handler: H) -> Self
pub fn with_hoop<H: Handler>(handler: H) -> Self
Add a handler as middleware, it will run the handler in current router or it’s descendants handle the request.
sourcepub fn hoop<H: Handler>(self, handler: H) -> Self
pub fn hoop<H: Handler>(self, handler: H) -> Self
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) -> Self where
T: Fn(&mut Request, &mut PathState) -> bool + Send + Sync + 'static,
pub fn filter_fn<T>(self, func: T) -> Self where
T: Fn(&mut Request, &mut PathState) -> bool + Send + Sync + 'static,
Create a new FnFilter from Fn.
sourcepub fn then<F>(self, func: F) -> Self where
F: FnOnce(Self) -> Self,
pub fn then<F>(self, func: F) -> Self where
F: FnOnce(Self) -> Self,
When you want write router chain, this function will be useful, You can write your custom logic in FnOnce.
sourcepub fn get<H: Handler>(self, handler: H) -> Self
pub fn get<H: Handler>(self, handler: H) -> Self
Create a new child router with MethodFilter to filter get method and set this child router’s handler.
sourcepub fn post<H: Handler>(self, handler: H) -> Self
pub fn post<H: Handler>(self, handler: H) -> Self
Create a new child router with MethodFilter to filter post method and set this child router’s handler.
sourcepub fn put<H: Handler>(self, handler: H) -> Self
pub fn put<H: Handler>(self, handler: H) -> Self
Create a new child router with MethodFilter to filter put method and set this child router’s handler.
sourcepub fn delete<H: Handler>(self, handler: H) -> Self
pub fn delete<H: Handler>(self, handler: H) -> Self
Create a new child router with MethodFilter to filter delete method and set this child router’s handler.
sourcepub fn patch<H: Handler>(self, handler: H) -> Self
pub fn patch<H: Handler>(self, handler: H) -> Self
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