pub trait RequestHandler {
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A function that takes a request and returns a response.
This is the main building block of a Cot app. You shouldn’t
usually need to implement this directly, as it is already
implemented for closures and functions that take a Request
and return a Result<Response>.
Required Methods§
Sourcefn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle the request and returns a response.
§Errors
This method can return an error if the request handler fails to handle the request.