pub trait HttpServiceFactory {
type Error;
type Service: HttpService;
// Required method
fn new_service(
&mut self,
remote_addr: SocketAddr,
) -> impl Future<Output = Result<Self::Service, Self::Error>> + Send;
}
Expand description
A trait representing an HTTP service factory.
This trait must be implemented by types that can create new instances of HttpService
.
It is conceptually similar to tower’s MakeService
trait.
It is intended to create a new service for each incoming connection.
If you don’t need to implement any custom factory logic, you can use ServiceCloneFactory
to make a factory that clones the given service for each new connection.
Required Associated Types§
Sourcetype Error
type Error
The error type that can be returned by new_service
.
Sourcetype Service: HttpService
type Service: HttpService
The service type that is created by this factory.
Required Methods§
Sourcefn new_service(
&mut self,
remote_addr: SocketAddr,
) -> impl Future<Output = Result<Self::Service, Self::Error>> + Send
fn new_service( &mut self, remote_addr: SocketAddr, ) -> impl Future<Output = Result<Self::Service, Self::Error>> + Send
Create a new service for a new connection.
remote_addr
is the address of the connecting remote peer.
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.
Implementors§
Source§impl<F, Fut, E, S> HttpServiceFactory for FnHttpServiceFactory<F>where
F: Fn(SocketAddr) -> Fut,
Fut: Future<Output = Result<S, E>> + Send,
E: Error,
S: HttpService,
impl<F, Fut, E, S> HttpServiceFactory for FnHttpServiceFactory<F>where
F: Fn(SocketAddr) -> Fut,
Fut: Future<Output = Result<S, E>> + Send,
E: Error,
S: HttpService,
Source§impl<M> HttpServiceFactory for TowerMakeServiceWithAddrFactory<M>
Available on crate feature tower
only.
impl<M> HttpServiceFactory for TowerMakeServiceWithAddrFactory<M>
tower
only.type Error = <M as MakeService<SocketAddr, Request<IncomingBody>>>::MakeError
type Service = <M as MakeService<SocketAddr, Request<IncomingBody>>>::Service
Source§impl<M, T> HttpServiceFactory for TowerMakeServiceFactory<M, T>where
M: MakeService<T, IncomingRequest> + Send,
M::Future: Send,
M::Service: HttpService,
T: Clone + Send,
Available on crate feature tower
only.
impl<M, T> HttpServiceFactory for TowerMakeServiceFactory<M, T>where
M: MakeService<T, IncomingRequest> + Send,
M::Future: Send,
M::Service: HttpService,
T: Clone + Send,
tower
only.