Struct hyper::server::Server
[−]
[src]
pub struct Server<L = HttpListener> { // some fields omitted }
A server can listen on a TCP socket.
Once listening, it will create a Request
/Response
pair for each
incoming connection, and hand them to the provided handler.
Methods
impl<L: NetworkListener> Server<L>
fn new(listener: L) -> Server<L>
Creates a new server with the provided handler.
fn keep_alive(&mut self, timeout: Duration)
Enables keep-alive for this server.
The timeout duration passed will be used to determine how long to keep the connection alive before dropping it.
NOTE: The timeout will only be used when the timeouts
feature
is enabled for hyper, and rustc is 1.4 or greater.
impl Server<HttpListener>
fn http<To: ToSocketAddrs>(addr: To) -> Result<Server<HttpListener>>
Creates a new server that will handle HttpStream
s.
impl<S: Ssl + Clone + Send> Server<HttpsListener<S>>
fn https<A: ToSocketAddrs>(addr: A, ssl: S) -> Result<Server<HttpsListener<S>>>
Creates a new server that will handle HttpStream
s over SSL.
You can use any SSL implementation, as long as implements hyper::net::Ssl
.
impl<L: NetworkListener + Send + 'static> Server<L>
fn handle<H: Handler + 'static>(self, handler: H) -> Result<Listening>
Binds to a socket and starts handling connections.
fn handle_threads<H: Handler + 'static>(self, handler: H, threads: usize) -> Result<Listening>
Binds to a socket and starts handling connections with the provided number of threads.