pub fn listen(mut self, lst: net::TcpListener) -> io::Result<Self> {
        let cfg = self.config.clone();
        let factory = self.factory.clone();
        let addr = lst.local_addr().unwrap();
        self.sockets.push(Socket {
            addr,
            scheme: "http",
        });
        let on_connect_fn = self.on_connect_fn.clone();

        self.builder =
            self.builder
                .listen(format!("actix-web-service-{}", addr), lst, move || {
                    let c = cfg.lock().unwrap();
                    let host = c.host.clone().unwrap_or_else(|| format!("{}", addr));

                    let mut svc = HttpService::build()
                        .keep_alive(c.keep_alive)
                        .client_timeout(c.client_timeout)
                        .client_disconnect(c.client_shutdown)
                        .local_addr(addr);

                    if let Some(handler) = on_connect_fn.clone() {
                        svc = svc.on_connect_ext(move |io: &_, ext: _| {
                            (handler)(io as &dyn Any, ext)
                        })
                    };

                    let fac = factory()
                        .into_factory()
                        .map_err(|err| err.into().error_response());

                    svc.finish(map_config(fac, move |_| {
                        AppConfig::new(false, host.clone(), addr)
                    }))
                    .tcp()
                })?;
        Ok(self)
    }
/// Use listener for accepting incoming connection requests
///
/// HttpServer does not change any configuration for TcpListener,
/// it needs to be configured before passing it to listen() method.
Use listener for accepting incoming connection requests
HttpServer does not change any configuration for TcpListener,
it needs to be configured before passing it to listen() method.
Use listener for accepting incoming connection requests HttpServer does not change any configuration for TcpListener it needs to be configured before passing it to listen () method .
pub fn listen(mut self, lst: net::TcpListener) -> io::Result<Self> {
        let cfg = self.config.clone();
        let factory = self.factory.clone();
        let addr = lst.local_addr().unwrap();
        self.sockets.push(Socket {
            addr,
            scheme: "http",
        });
        let on_connect_fn = self.on_connect_fn.clone();
        self.builder =
            self.builder
                .listen(format!("actix-web-service-{}", addr), lst, move || {
                    let c = cfg.lock().unwrap();
                    let host = c.host.clone().unwrap_or_else(|| format!("{}", addr));
                    let mut svc = HttpService::build()
                        .keep_alive(c.keep_alive)
                        .client_timeout(c.client_timeout)
                        .client_disconnect(c.client_shutdown)
                        .local_addr(addr);
                    if let Some(handler) = on_connect_fn.clone() {
                        svc = svc.on_connect_ext(move |io: &_, ext: _| {
                            (handler)(io as &dyn Any, ext)
                        })
                    };
                    let fac = factory()
                        .into_factory()
                        .map_err(|err| err.into().error_response());
                    svc.finish(map_config(fac, move |_| {
                        AppConfig::new(false, host.clone(), addr)
                    }))
                    .tcp()
                })?;
        Ok(self)
    }
pub fn listen ( mut self , lst : net :: TcpListener ) -> io :: Result < Self > { let cfg = self . config . clone ( ) ; let factory = self . factory . clone ( ) ; let addr = lst . local_addr ( ) . unwrap ( ) ; self . sockets . push ( Socket { addr , scheme : " " , } ) ; let on_connect_fn = self . on_connect_fn . clone ( ) ; self . builder = self . builder . listen ( format ! ( " " addr ) , lst , move | | { let c = cfg . lock ( ) . unwrap ( ) ; let host = c . host . clone ( ) . unwrap_or_else ( | | format ! ( " " addr ) ) ; let mut svc = HttpService :: build ( ) . keep_alive ( c . keep_alive ) . client_timeout ( c . client_timeout ) . client_disconnect ( c . client_shutdown ) . local_addr ( addr ) ; if let Some ( handler ) = on_connect_fn . clone ( ) { svc = svc . on_connect_ext ( move | io : & _ , ext : _ | { ( handler ) ( io as & dyn Any , ext ) } ) } ; let fac = factory ( ) . into_factory ( ) . map_err ( | err | err . into ( ) . error_response ( ) ) ; svc . finish ( map_config ( fac , move | _ | { AppConfig :: new ( false , host . clone ( ) , addr ) } ) ) . tcp ( ) } ) ? ; Ok ( self ) }
Use listener for accepting incoming connection requests
HttpServer does not change any configuration for TcpListener,
it needs to be configured before passing it to listen() method.
Use listener for accepting incoming connection requests HttpServer does not change any configuration for TcpListener it needs to be configured before passing it to listen () method .
mut self
lst
net::TcpListener
mut self
lst
net::TcpListener