Skip to main content

actix_http/h1/
expect.rs

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