Struct salvo_core::Router [−][src]
pub struct Router { /* fields omitted */ }
Implementations
impl Router
[src]
impl Router
[src]pub fn new() -> Router
[src]
Create a new Router.
pub fn routers(&self) -> &Vec<Router>
[src]
Get current router’s children reference.
pub fn routers_mut(&mut self) -> &mut Vec<Router>
[src]
Get current router’s children mutable reference.
pub fn befores(&self) -> &Vec<Arc<dyn Handler>>
[src]
Get current router’s before middlewares reference.
pub fn befores_mut(&mut self) -> &mut Vec<Arc<dyn Handler>>
[src]
Get current router’s before middlewares mutable reference.
pub fn afters(&self) -> &Vec<Arc<dyn Handler>>
[src]
Get current router’s after middlewares reference.
pub fn afters_mut(&mut self) -> &mut Vec<Arc<dyn Handler>>
[src]
Get current router’s after middlewares mutable reference.
pub fn filters(&self) -> &Vec<Box<dyn Filter>>
[src]
Get current router’s filters reference.
pub fn filters_mut(&mut self) -> &mut Vec<Box<dyn Filter>>
[src]
Get current router’s filters mutable reference.
pub fn detect(
&self,
req: &mut Request,
path_state: &mut PathState
) -> Option<DetectMatched>
[src]
&self,
req: &mut Request,
path_state: &mut PathState
) -> Option<DetectMatched>
Detect current router is matched for current request.
pub fn push(self, router: Router) -> Self
[src]
Push a router as child of current router.
pub fn append(self, others: Vec<Router>) -> Self
[src]
Append all routers in a Vec as children of current router.
pub fn push_when<F>(self, func: F) -> Self where
F: Fn(&Router) -> Option<Router>,
[src]
F: Fn(&Router) -> Option<Router>,
Please use then function instead
pub fn before<H: Handler>(self, handler: H) -> Self
[src]
Add a handler as middleware, it will run before the handler in current router or it’s descendants handle the request.
pub fn after<H: Handler>(self, handler: H) -> Self
[src]
Add a handler as middleware, it will run after the handler in current router or it’s descendants handle the request.
pub fn path(self, path: impl Into<String>) -> Self
[src]
pub fn filter(self, filter: impl Filter + Sized) -> Self
[src]
Add a filter for current router.
pub fn filter_fn<T>(self, func: T) -> Self where
T: Fn(&mut Request, &mut PathState) -> bool + Send + Sync + 'static,
[src]
T: Fn(&mut Request, &mut PathState) -> bool + Send + Sync + 'static,
Create a new FnFilter from Fn.
pub fn handle<H: Handler>(self, handler: H) -> Self
[src]
Set current router’s handler.
pub fn then<F>(self, func: F) -> Self where
F: FnOnce(Self) -> Self,
[src]
F: FnOnce(Self) -> Self,
When you want write router chain, this function will be useful, You can write your custom logic in FnOnce.
pub fn get<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter get method and set this child router’s handler.
pub fn post<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter post method and set this child router’s handler.
pub fn put<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter put method and set this child router’s handler.
pub fn delete<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter delete method and set this child router’s handler.
pub fn patch<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter patch method and set this child router’s handler.
pub fn head<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter head method and set this child router’s handler.
pub fn options<H: Handler>(self, handler: H) -> Self
[src]
Create a new child router with MethodFilter to filter options method and set this child router’s handler.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Router
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl !UnwindSafe for Router
Blanket Implementations
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,