Skip to main content

Handler

Trait Handler 

Source
pub trait Handler:
    Send
    + Sync
    + 'static {
    // Required method
    fn call(&self, ctx: Context) -> BoxFuture<Response>;
}
Expand description

Something that turns a request into a response.

Implemented for any async fn(Context) -> impl IntoResponse, so plain functions and closures can be used as route handlers.

Required Methods§

Source

fn call(&self, ctx: Context) -> BoxFuture<Response>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F, Fut, R> Handler for F
where F: Fn(Context) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send + 'static, R: IntoResponse,