actix_http/h1/
expect.rs

1use actix_service::{Service, ServiceFactory};
2use actix_utils::future::{ready, Ready};
3
4use crate::{Error, Request};
5
6pub struct ExpectHandler;
7
8impl ServiceFactory<Request> for ExpectHandler {
9    type Response = Request;
10    type Error = Error;
11    type Config = ();
12    type Service = ExpectHandler;
13    type InitError = Error;
14    type Future = Ready<Result<Self::Service, Self::InitError>>;
15
16    fn new_service(&self, _: Self::Config) -> Self::Future {
17        ready(Ok(ExpectHandler))
18    }
19}
20
21impl Service<Request> for ExpectHandler {
22    type Response = Request;
23    type Error = Error;
24    type Future = Ready<Result<Self::Response, Self::Error>>;
25
26    actix_service::always_ready!();
27
28    fn call(&self, req: Request) -> Self::Future {
29        ready(Ok(req))
30        // TODO: add some way to trigger error
31        // Err(error::ErrorExpectationFailed("test"))
32    }
33}