pub trait RequestHandler: Service<HttpRequest, Out = Result<HttpResponse>> { }Expand description
Trait alias for Service<HttpRequest, Out = Result<HttpResponse>>.
Use RequestHandler as a trait bound to avoid spelling out the full
Service<HttpRequest, Out = Result<HttpResponse>> constraint. Any type that
implements Service<HttpRequest> with Out = Result<HttpResponse>
automatically implements RequestHandler.
§Examples
struct MyHandler<S>(S);
impl<S: RequestHandler> Service<HttpRequest> for MyHandler<S> {
type Out = Result<HttpResponse>;
async fn execute(&self, request: HttpRequest) -> Self::Out {
// Custom processing, then delegate to the inner handler.
self.0.execute(request).await
}
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".