mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 01:11:07 +01:00
fix startup fail example
This commit is contained in:
parent
4c0eaca581
commit
9b9869f1dd
@ -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::<u32, u32>(42) }),
|
||||
fn_factory(|| async move {
|
||||
if 1 > 2 {
|
||||
Ok(fn_service(move |mut _stream: TcpStream| async move {
|
||||
Ok::<u32, u32>(0)
|
||||
}))
|
||||
} else {
|
||||
Err(42)
|
||||
}
|
||||
}),
|
||||
)?
|
||||
.workers(2)
|
||||
.run()
|
||||
|
@ -87,7 +87,7 @@ async fn main() -> io::Result<()> {
|
||||
|
||||
svc2
|
||||
})?
|
||||
.workers(1)
|
||||
.workers(2)
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
@ -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<Req>: Service<Req> {
|
||||
|
Loading…
Reference in New Issue
Block a user