/// Start new test server with application factory
Start new test server with application factory
Start new test server with application factory
fn with_factory<F, H>(factory: F) -> Self
    where
        F: Fn() -> H + Send + Clone + 'static,
        H: IntoHttpHandler + 'static,
    {
        let (tx, rx) = mpsc::channel();
        // run server in separate thread
        let handle = thread::spawn(move || {
            let sys = System::new("actix-test-server");
            let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap();
            let local_addr = tcp.local_addr().unwrap();
            let srv = HttpServer::new(factory)
                .disable_signals()
                .listen(tcp)
                .keep_alive(5)
                .workers(1)
                .start();
            tx.send((System::current(), local_addr, srv)).unwrap();
            sys.run();
        });
        let (system, addr, backend) = rx.recv().unwrap();
        Self {
            addr,
            backend,
            handle: Some(handle),
            system,
        }
    }
fn with_factory < F , H > ( factory : F ) -> Self where F : Fn ( ) -> H + Send + Clone + ' static , H : IntoHttpHandler + ' static , { let ( tx , rx ) = mpsc :: channel ( ) ; // run server in separate thread let handle = thread :: spawn ( move | | { let sys = System :: new ( " " ) ; let tcp = net :: TcpListener :: bind ( " " ) . unwrap ( ) ; let local_addr = tcp . local_addr ( ) . unwrap ( ) ; let srv = HttpServer :: new ( factory ) . disable_signals ( ) . listen ( tcp ) . keep_alive ( 5 ) . workers ( 1 ) . start ( ) ; tx . send ( ( System :: current ( ) , local_addr , srv ) ) . unwrap ( ) ; sys . run ( ) ; } ) ; let ( system , addr , backend ) = rx . recv ( ) . unwrap ( ) ; Self { addr , backend , handle : Some ( handle ) , system , } }
Start new test server with application factory
Start new test server with application factory
factory
F