Skip to main content

Handler

Trait Handler 

Source
pub trait Handler {
    type Output: IntoFunctionResponse;
    type Future: Future<Output = Self::Output> + Send + 'static;

    // Required method
    fn call(&self, req: Request, state: AppState) -> Self::Future;
}
Expand description

Trait that abstracts over handler function signatures that return types implementing IntoFunctionResponse

Required Associated Types§

Source

type Output: IntoFunctionResponse

Source

type Future: Future<Output = Self::Output> + Send + 'static

Required Methods§

Source

fn call(&self, req: Request, state: AppState) -> Self::Future

Implementors§

Source§

impl<F, Fut, R> Handler for StatelessHandler<F>
where F: Fn(Request) -> Fut + Clone + Send + 'static, Fut: Future<Output = R> + Send + 'static, R: IntoFunctionResponse,

Source§

type Output = R

Source§

type Future = Fut

Source§

impl<F, Fut, R> Handler for F
where F: Fn(Request, AppState) -> Fut + Clone + Send + 'static, Fut: Future<Output = R> + Send + 'static, R: IntoFunctionResponse,

Implementation for handlers that return IntoFunctionResponse types

Source§

type Output = R

Source§

type Future = Fut