pub fn factory<Sf, St, Req>(
factory: impl IntoServiceFactory<Sf, St, Req>,
) -> ServiceChainFactory<Sf, St, Req>where
Sf: ServiceFactory<St, Req>,Expand description
Starts a ServiceChainFactory with one service factory.
Converts the input through IntoServiceFactory without creating a
service. Combinators configure how services will be created and composed.
Use ServiceChainFactory::pipeline to create a service and bind it to
its state, or ServiceFactory::create to obtain the service alone.
ยงExample
use ntex_service::{factory, fn_factory, fn_service};
let factory = factory(fn_factory(async |offset: &u32| {
let offset = *offset;
Ok::<_, ()>(fn_service(async move |req: u32| Ok::<_, ()>(req + offset)))
}))
.and_then(fn_factory(async |_: &u32| {
Ok::<_, ()>(fn_service(async |value: u32| Ok::<_, ()>(value * 2)))
}));
let pipeline = factory.pipeline(10).await?;
assert_eq!(pipeline.call(2).await?, 24);