diff --git a/src/server.rs b/src/server.rs index 70448fdce..3badb6e8d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -127,19 +127,7 @@ where _t: PhantomData, } } -} -impl HttpServer -where - F: Fn() -> I + Send + Clone + 'static, - I: IntoServiceFactory, - S: ServiceFactory, - S::Error: Into + 'static, - S::InitError: fmt::Debug, - S::Response: Into> + 'static, - ::Future: 'static, - B: MessageBody + 'static, -{ /// Set number of workers to start. /// /// By default http server uses number of available logical cpu as threads diff --git a/tests/test_on_connect.rs b/tests/test_on_connect.rs deleted file mode 100644 index 8f24c5ff9..000000000 --- a/tests/test_on_connect.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::{any::Any, env, io, net::SocketAddr}; - -use actix_web::{dev::Extensions, rt::net::TcpStream, web, App, HttpServer}; - -#[derive(Debug, Clone)] -struct ConnectionInfo { - bind: SocketAddr, - peer: SocketAddr, - ttl: Option, -} - -async fn route_whoami(conn_info: web::ReqData) -> String { - format!( - "Here is some info about your connection:\n\n{:#?}", - conn_info - ) -} - -fn get_conn_info(connection: &dyn Any, data: &mut Extensions) { - if let Some(sock) = connection.downcast_ref::() { - data.insert(ConnectionInfo { - bind: sock.local_addr().unwrap(), - peer: sock.peer_addr().unwrap(), - ttl: sock.ttl().ok(), - }); - } else { - unreachable!("connection should only be plaintext since no TLS is set up"); - } -} - -#[actix_web::main] -async fn main() -> io::Result<()> { - if env::var("RUST_LOG").is_err() { - env::set_var("RUST_LOG", "info"); - } - - env_logger::init(); - - HttpServer::new(|| App::new().default_service(web::to(route_whoami))) - .on_connect(get_conn_info) - .bind(("127.0.0.1", 8080))? - .workers(1) - .run() - .await -}