pub fn listen_with<A: ToSocketAddrs>(mut self, addr: A, threads: usize,
                                         protocol: Protocol,
                                         timeouts: Option<Timeouts>) -> HttpResult<Listening> {
        let sock_addr = addr.to_socket_addrs()
            .ok().and_then(|mut addrs| addrs.next()).expect("Could not parse socket address.");

        self.addr = Some(sock_addr);
        self.protocol = Some(protocol.clone());

        match protocol {
            Protocol::Http => {
                let mut server = try!(Server::http(sock_addr));
                let timeouts = timeouts.unwrap_or_default();
                server.keep_alive(timeouts.keep_alive);
                server.set_read_timeout(timeouts.read);
                server.set_write_timeout(timeouts.write);
                server.handle_threads(self, threads)
            },

            #[cfg(feature = "ssl")]
            Protocol::Https { ref certificate, ref key } => {
                use hyper::net::Openssl;

                let ssl = try!(Openssl::with_cert_and_key(certificate, key));
                let mut server = try!(Server::https(sock_addr, ssl));
                let timeouts = timeouts.unwrap_or_default();
                server.keep_alive(timeouts.keep_alive);
                server.set_read_timeout(timeouts.read);
                server.set_write_timeout(timeouts.write);
                server.handle_threads(self, threads)
            }
        }
    }
/// Kick off the server process with X threads.
///
/// ## Panics
///
/// Panics if the provided address does not parse. To avoid this
/// call `to_socket_addrs` yourself and pass a parsed `SocketAddr`.
Kick off the server process with X threads.
Kick off the server process with X threads .
pub fn listen_with<A: ToSocketAddrs>(mut self, addr: A, threads: usize,
                                         protocol: Protocol,
                                         timeouts: Option<Timeouts>) -> HttpResult<Listening> {
        let sock_addr = addr.to_socket_addrs()
            .ok().and_then(|mut addrs| addrs.next()).expect("Could not parse socket address.");
        self.addr = Some(sock_addr);
        self.protocol = Some(protocol.clone());
        match protocol {
            Protocol::Http => {
                let mut server = try!(Server::http(sock_addr));
                let timeouts = timeouts.unwrap_or_default();
                server.keep_alive(timeouts.keep_alive);
                server.set_read_timeout(timeouts.read);
                server.set_write_timeout(timeouts.write);
                server.handle_threads(self, threads)
            },
            #[cfg(feature = "ssl")]
            Protocol::Https { ref certificate, ref key } => {
                use hyper::net::Openssl;
                let ssl = try!(Openssl::with_cert_and_key(certificate, key));
                let mut server = try!(Server::https(sock_addr, ssl));
                let timeouts = timeouts.unwrap_or_default();
                server.keep_alive(timeouts.keep_alive);
                server.set_read_timeout(timeouts.read);
                server.set_write_timeout(timeouts.write);
                server.handle_threads(self, threads)
            }
        }
    }
pub fn listen_with < A : ToSocketAddrs > ( mut self , addr : A , threads : usize , protocol : Protocol , timeouts : Option < Timeouts > ) -> HttpResult < Listening > { let sock_addr = addr . to_socket_addrs ( ) . ok ( ) . and_then ( | mut addrs | addrs . next ( ) ) . expect ( " " ) ; self . addr = Some ( sock_addr ) ; self . protocol = Some ( protocol . clone ( ) ) ; match protocol { Protocol :: Http => { let mut server = try ! ( Server http ( sock_addr ) ) ; let timeouts = timeouts . unwrap_or_default ( ) ; server . keep_alive ( timeouts . keep_alive ) ; server . set_read_timeout ( timeouts . read ) ; server . set_write_timeout ( timeouts . write ) ; server . handle_threads ( self , threads ) } , # [ cfg ( feature " " ) ] Protocol :: Https { ref certificate , ref key } => { use hyper :: net :: Openssl ; let ssl = try ! ( Openssl with_cert_and_key ( certificate key ) ) ; let mut server = try ! ( Server https ( sock_addr ssl ) ) ; let timeouts = timeouts . unwrap_or_default ( ) ; server . keep_alive ( timeouts . keep_alive ) ; server . set_read_timeout ( timeouts . read ) ; server . set_write_timeout ( timeouts . write ) ; server . handle_threads ( self , threads ) } } }
Kick off the server process with X threads.
Kick off the server process with X threads .
mut self
addr
A
threads
usize
protocol
Protocol
timeouts
Option<Timeouts>
panics
Panics if the provided address does not parse. To avoid this
call `to_socket_addrs` yourself and pass a parsed `SocketAddr`.
Panics if the provided address does not parse . To avoid this call ` to_socket_addrs ` yourself and pass a parsed ` SocketAddr ` .