Skip to main content

ControllerHandler

Trait ControllerHandler 

Source
pub trait ControllerHandler: Send + Sync {
    // Required method
    fn call<'a>(
        &'a self,
        ctx: &'a mut Context,
    ) -> Pin<Box<dyn Future<Output = ControllerResult> + Send + 'a>>;
}
Expand description

Trait for controller functions that can be stored in the registry.

Required Methods§

Source

fn call<'a>( &'a self, ctx: &'a mut Context, ) -> Pin<Box<dyn Future<Output = ControllerResult> + Send + 'a>>

Implementors§

Source§

impl<F> ControllerHandler for F
where F: for<'a> AsyncControllerFn<'a> + Send + Sync,

Blanket implementation for named async functions that take &mut Context.

Use named async functions (not closures) for controller registration:

async fn normalize_email(ctx: &mut Context) -> ControllerResult {
    // modify ctx.input...
    Ok(())
}
map.register("users", "normalize_email", normalize_email);