pub trait Handler: 'static + Send + Sync {
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>
where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait;
}
Expand description
Handler
is used for handle Request
.
Handler
can be used as middleware to handleRequest
.
Example
use salvo_core::prelude::*;
#[handler]
async fn middleware() {
}
#[tokio::main]
async fn main() {
Router::new().hoop(middleware);
}
Handler
can be used as endpoint to handleRequest
.
Example
#[handler]
async fn middleware() {
}
#[tokio::main]
async fn main() {
Router::new().handle(middleware);
}
Required Methods
sourcefn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Handle http request.