Struct salvo::Router[][src]

pub struct Router { /* fields omitted */ }

Implementations

impl Router[src]

pub fn new() -> Router[src]

Create a new Router.

pub fn routers(&self) -> &Vec<Router, Global>[src]

Get current router’s children reference.

pub fn routers_mut(&mut self) -> &mut Vec<Router, Global>[src]

Get current router’s children mutable reference.

pub fn befores(&self) -> &Vec<Arc<dyn Handler + 'static>, Global>[src]

Get current router’s before middlewares reference.

pub fn befores_mut(&mut self) -> &mut Vec<Arc<dyn Handler + 'static>, Global>[src]

Get current router’s before middlewares mutable reference.

pub fn afters(&self) -> &Vec<Arc<dyn Handler + 'static>, Global>[src]

Get current router’s after middlewares reference.

pub fn afters_mut(&mut self) -> &mut Vec<Arc<dyn Handler + 'static>, Global>[src]

Get current router’s after middlewares mutable reference.

pub fn filters(&self) -> &Vec<Box<dyn Filter + 'static, Global>, Global>[src]

Get current router’s filters reference.

pub fn filters_mut(
    &mut self
) -> &mut Vec<Box<dyn Filter + 'static, Global>, Global>
[src]

Get current router’s filters mutable reference.

pub fn detect(
    &self,
    req: &mut Request,
    path_state: &mut PathState
) -> Option<DetectMatched>
[src]

Detect current router is matched for current request.

pub fn push(self, router: Router) -> Router[src]

Push a router as child of current router.

pub fn append(self, others: Vec<Router, Global>) -> Router[src]

Append all routers in a Vec as children of current router.

pub fn push_when<F>(self, func: F) -> Router where
    F: Fn(&Router) -> Option<Router>, 
[src]

👎 Deprecated since 0.10.4:

Please use then function instead

pub fn before<H>(self, handler: H) -> Router where
    H: Handler
[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>(self, handler: H) -> Router where
    H: Handler
[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>) -> Router[src]

Create a new path filter for current router.

Panics

Panics if path value is not in correct format.

pub fn filter(self, filter: impl Filter) -> Router[src]

Add a filter for current router.

pub fn filter_fn<T>(self, func: T) -> Router where
    T: Fn(&mut Request, &mut PathState) -> bool + Send + Sync + 'static, 
[src]

Create a new FnFilter from Fn.

pub fn handle<H>(self, handler: H) -> Router where
    H: Handler
[src]

Set current router’s handler.

pub fn then<F>(self, func: F) -> Router where
    F: FnOnce(Router) -> Router
[src]

When you want write router chain, this function will be useful, You can write your custom logic in FnOnce.

pub fn get<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter get method and set this child router’s handler.

pub fn post<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter post method and set this child router’s handler.

pub fn put<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter put method and set this child router’s handler.

pub fn delete<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter delete method and set this child router’s handler.

pub fn patch<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter patch method and set this child router’s handler.

pub fn head<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter head method and set this child router’s handler.

pub fn options<H>(self, handler: H) -> Router where
    H: Handler
[src]

Create a new child router with MethodFilter to filter options method and set this child router’s handler.

Trait Implementations

impl Default for Router[src]

pub fn default() -> Router[src]

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V