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

add new service configuration

This commit is contained in:
Nikolay Kim
2018-08-21 17:08:23 -07:00
parent 2cbcc21168
commit b8c8dbc90a
9 changed files with 247 additions and 107 deletions

View File

@ -20,8 +20,7 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_openssl::SslAcceptorExt;
use actix_net::service::{IntoNewService, NewServiceExt};
use actix_net::Server;
use actix_net::{IntoNewService, NewService, Server};
/// Simple logger service, it just prints fact of the new connections
fn logger<T: AsyncRead + AsyncWrite + fmt::Debug>(
@ -90,7 +89,7 @@ fn main() {
Ok::<_, io::Error>(ServiceState { num: num.clone() })
}));
Server::new().bind("0.0.0.0:8443", srv).unwrap().start();
Server::default().bind("0.0.0.0:8443", srv).unwrap().start();
sys.run();
}

View File

@ -15,8 +15,7 @@ use futures::{future, Future};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use tokio_io::{AsyncRead, AsyncWrite};
use actix_net::service::NewServiceExt;
use actix_net::{ssl, Server};
use actix_net::{ssl, NewService, Server};
#[derive(Debug)]
struct ServiceState {
@ -24,7 +23,7 @@ struct ServiceState {
}
fn service<T: AsyncRead + AsyncWrite>(
st: &mut ServiceState, stream: T,
st: &mut ServiceState, _: T,
) -> impl Future<Item = (), Error = io::Error> {
let num = st.num.fetch_add(1, Ordering::Relaxed);
println!("got ssl connection {:?}", num);
@ -50,7 +49,7 @@ fn main() {
Ok::<_, io::Error>(ServiceState { num: num.clone() })
}));
Server::new().bind("0.0.0.0:8443", srv).unwrap().start();
Server::default().bind("0.0.0.0:8443", srv).unwrap().start();
sys.run();
}