2021-10-25 18:03:52 +01:00
|
|
|
use std::io;
|
|
|
|
|
|
|
|
use actix_rt::net::TcpStream;
|
|
|
|
use actix_server::Server;
|
2021-10-25 18:13:08 +01:00
|
|
|
use actix_service::{fn_factory, fn_service};
|
2021-10-25 18:03:52 +01:00
|
|
|
use log::info;
|
|
|
|
|
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() -> io::Result<()> {
|
|
|
|
env_logger::Builder::from_env(env_logger::Env::new().default_filter_or("trace,mio=info"))
|
|
|
|
.init();
|
|
|
|
|
|
|
|
let addr = ("127.0.0.1", 8080);
|
|
|
|
info!("starting server on port: {}", &addr.0);
|
|
|
|
|
|
|
|
Server::build()
|
|
|
|
.bind(
|
|
|
|
"startup-fail",
|
|
|
|
addr,
|
2021-10-25 18:13:08 +01:00
|
|
|
fn_factory(|| async move {
|
|
|
|
if 1 > 2 {
|
|
|
|
Ok(fn_service(move |mut _stream: TcpStream| async move {
|
|
|
|
Ok::<u32, u32>(0)
|
|
|
|
}))
|
|
|
|
} else {
|
|
|
|
Err(42)
|
|
|
|
}
|
|
|
|
}),
|
2021-10-25 18:03:52 +01:00
|
|
|
)?
|
|
|
|
.workers(2)
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|