Trait actix_web::dev::ServiceFactory
pub trait ServiceFactory<Req> {
type Response;
type Error;
type Config;
type Service: Service<Req, Response = Self::Response, Error = Self::Error>;
type InitError;
type Future: Future<Output = Result<Self::Service, Self::InitError>>;
// Required method
fn new_service(&self, cfg: Self::Config) -> Self::Future;
}Expand description
Factory for creating Services.
This is useful for cases where new Services must be produced. One case is a TCP
server listener: a listener accepts new connections, constructs a new Service for each using
the ServiceFactory trait, and uses the new Service to process inbound requests on that new
connection.
Config is a service factory configuration type.
Simple factories may be able to use fn_factory or [fn_factory_with_config] to
reduce boilerplate.
Required Associated Types§
type Response
type Response
Responses given by the created services.
type Error
type Error
Errors produced by the created services.
type Config
type Config
Service factory configuration.
type Service: Service<Req, Response = Self::Response, Error = Self::Error>
type Service: Service<Req, Response = Self::Response, Error = Self::Error>
The kind of Service created by this factory.
type InitError
type InitError
Errors potentially raised while building a service.
Required Methods§
fn new_service(&self, cfg: Self::Config) -> Self::Future
fn new_service(&self, cfg: Self::Config) -> Self::Future
Create and return a new service asynchronously.