#[handler]
Expand description
handler
is a pro macro to help create Handler
from function or impl block easily.
Handler
is a trait, if #[handler]
applied to fn
, fn
will converted to a struct, and then implement Handler
.
ⓘ
#[async_trait]
pub trait Handler: Send + Sync + 'static {
async fn handle(&self, req: &mut Request, depot: &mut Depot, res: &mut Response, ctrl: &mut FlowCtrl);
}
After use handler
, you don’t need to care arguments’ order, omit unused arguments:
ⓘ
#[handler]
async fn hello_world() -> &'static str {
"Hello World"
}