pub trait Handler: Sync + Send {
type RespBody: Body;
type Error: Into<Box<dyn Error + Send + Sync>>;
// Required method
fn call(
&self,
req: Request<ReqBody>,
) -> impl Future<Output = Result<Response<Self::RespBody>, Self::Error>> + Send;
}
Expand description
A trait for handling HTTP requests
This trait defines the core interface for processing HTTP requests and generating responses. Implementors of this trait can be used to handle requests in the HTTP server.
§Type Parameters
RespBody
: The response body type that implementsBody
Error
: The error type that can be converted into a boxed errorFut
: The future type returned by the handler
Required Associated Types§
Required Methods§
fn call( &self, req: Request<ReqBody>, ) -> impl Future<Output = Result<Response<Self::RespBody>, Self::Error>> + Send
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.