1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 06:20:36 +02:00

remove custom NewService and cleanups

This commit is contained in:
Nikolay Kim
2018-08-23 15:42:34 -07:00
parent 1261ecbce0
commit a5a026b5c4
9 changed files with 92 additions and 292 deletions

View File

@ -20,7 +20,7 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_openssl::SslAcceptorExt;
use actix_net::{IntoNewService, NewService, Server};
use actix_net::{IntoNewService, NewServiceExt, Server};
/// Simple logger service, it just prints fact of the new connections
fn logger<T: AsyncRead + AsyncWrite + fmt::Debug>(

View File

@ -15,7 +15,7 @@ use futures::{future, Future};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use tokio_io::{AsyncRead, AsyncWrite};
use actix_net::{ssl, NewService, Server};
use actix_net::{ssl, NewServiceExt, Server};
#[derive(Debug)]
struct ServiceState {
@ -46,14 +46,16 @@ fn main() {
let openssl = ssl::OpensslService::new(builder);
// server start mutiple workers, it runs supplied `Fn` in each worker.
Server::default().bind("0.0.0.0:8443", move || {
let num = num.clone();
Server::default()
.bind("0.0.0.0:8443", move || {
let num = num.clone();
// configure service
openssl.clone().and_then((service, move || {
Ok::<_, io::Error>(ServiceState { num: num.clone() })
}))
}).unwrap().start();
// configure service
openssl.clone().and_then((service, move || {
Ok::<_, io::Error>(ServiceState { num: num.clone() })
}))
}).unwrap()
.start();
sys.run();
}