scuffle_http/service/
clone_factory.rs1use std::net::SocketAddr;
2
3use super::{HttpService, HttpServiceFactory};
4
5#[derive(Clone, Debug)]
9pub struct ServiceCloneFactory<S>(S);
10
11pub fn service_clone_factory<S>(service: S) -> ServiceCloneFactory<S>
15where
16 S: HttpService + Clone + Send,
17{
18 ServiceCloneFactory(service)
19}
20
21impl<S> HttpServiceFactory for ServiceCloneFactory<S>
22where
23 S: HttpService + Clone + Send,
24{
25 type Error = std::convert::Infallible;
26 type Service = S;
27
28 async fn new_service(&mut self, _remote_addr: SocketAddr) -> Result<Self::Service, Self::Error> {
29 Ok(self.0.clone())
30 }
31}