Handler

Trait Handler 

Source
pub trait Handler: Sized {
    type Error;
    type Response: IntoResponse;
    type Fut: Future<Output = Result<Self::Response, Self::Error>> + 'static;

    // Required method
    fn call(&mut self, event: Request, context: Context) -> Self::Fut;
}
Expand description

Functions serving as ALB and API Gateway REST and HTTP API handlers must conform to this type.

This can be viewed as a lambda::Handler constrained to http crate Request and Response types

Required Associated Types§

Source

type Error

The type of Error that this Handler will return

Source

type Response: IntoResponse

The type of Response this Handler will return

Source

type Fut: Future<Output = Result<Self::Response, Self::Error>> + 'static

The type of Future this Handler will return

Required Methods§

Source

fn call(&mut self, event: Request, context: Context) -> Self::Fut

Function used to execute handler behavior

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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

An implementation of Handler for a given closure return a Future representing the computed response

Source§

type Response = R

Source§

type Error = Box<dyn Error + Sync + Send>

Source§

type Fut = Fut

Source§

impl<H: Handler> Handler for Adapter<H>

Source§

impl<H: Handler> Handler for ProxyAdapter<H>