diff --git a/actix-server/examples/startup-fail.rs b/actix-server/examples/startup-fail.rs index 9631b2d1..f26f441e 100644 --- a/actix-server/examples/startup-fail.rs +++ b/actix-server/examples/startup-fail.rs @@ -2,7 +2,7 @@ use std::io; use actix_rt::net::TcpStream; use actix_server::Server; -use actix_service::fn_service; +use actix_service::{fn_factory, fn_service}; use log::info; #[actix_rt::main] @@ -17,7 +17,15 @@ async fn main() -> io::Result<()> { .bind( "startup-fail", addr, - fn_service(move |mut _stream: TcpStream| async move { Ok::(42) }), + fn_factory(|| async move { + if 1 > 2 { + Ok(fn_service(move |mut _stream: TcpStream| async move { + Ok::(0) + })) + } else { + Err(42) + } + }), )? .workers(2) .run() diff --git a/actix-server/examples/tcp-echo.rs b/actix-server/examples/tcp-echo.rs index e5e288fc..dfe5e01e 100644 --- a/actix-server/examples/tcp-echo.rs +++ b/actix-server/examples/tcp-echo.rs @@ -87,7 +87,7 @@ async fn main() -> io::Result<()> { svc2 })? - .workers(1) + .workers(2) .run() .await } diff --git a/actix-service/src/ext.rs b/actix-service/src/ext.rs index 48ddb127..622b0f55 100644 --- a/actix-service/src/ext.rs +++ b/actix-service/src/ext.rs @@ -1,4 +1,10 @@ -use crate::{IntoService, IntoServiceFactory, Service, ServiceFactory, Transform, and_then::{AndThenSendServiceFactory, AndThenService, AndThenServiceFactory}, map::Map, map_err::MapErr, transform_err::TransformMapInitErr}; +use crate::{ + and_then::{AndThenSendServiceFactory, AndThenService, AndThenServiceFactory}, + map::Map, + map_err::MapErr, + transform_err::TransformMapInitErr, + IntoService, IntoServiceFactory, Service, ServiceFactory, Transform, +}; /// An extension trait for [`Service`]s that provides a variety of convenient adapters. pub trait ServiceExt: Service { diff --git a/actix-service/src/pipeline.rs b/actix-service/src/pipeline.rs index b3cb72f2..2c71a74b 100644 --- a/actix-service/src/pipeline.rs +++ b/actix-service/src/pipeline.rs @@ -175,13 +175,13 @@ where factory: I, ) -> PipelineFactory< impl ServiceFactory< - Req, - Response = SF1::Response, - Error = SF::Error, - Config = SF::Config, - InitError = SF::InitError, + Req, + Response = SF1::Response, + Error = SF::Error, + Config = SF::Config, + InitError = SF::InitError, Service = impl Service + Clone, - > + Clone, + > + Clone, Req, > where