diff --git a/src/server/mod.rs b/src/server/mod.rs index 258c059b..7234da69 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -257,6 +257,34 @@ impl + 'static> Http { /// /// This returns a Future that must be polled in order for HTTP to be /// driven on the connection. + /// + /// # Example + /// + /// ``` + /// # extern crate futures; + /// # extern crate hyper; + /// # extern crate tokio_core; + /// # extern crate tokio_io; + /// # use futures::Future; + /// # use hyper::server::{Http, Request, Response, Service}; + /// # use tokio_io::{AsyncRead, AsyncWrite}; + /// # use tokio_core::reactor::Handle; + /// # fn run(some_io: I, some_service: S, some_handle: &Handle) + /// # where + /// # I: AsyncRead + AsyncWrite + 'static, + /// # S: Service + 'static, + /// # { + /// let http = Http::::new(); + /// let conn = http.serve_connection(some_io, some_service); + /// + /// let fut = conn + /// .map(|_| ()) + /// .map_err(|e| eprintln!("server connection error: {}", e)); + /// + /// some_handle.spawn(fut); + /// # } + /// # fn main() {} + /// ``` pub fn serve_connection(&self, io: I, service: S) -> Connection where S: Service, Error = ::Error>, Bd: Stream,