Skip to content

Commit 5fdbd30

Browse files
committed
docs(examples): touch up Hello server example
1 parent 210bfaa commit 5fdbd30

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/hello.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ use hyper::service::service_fn;
1010
use hyper::{Request, Response};
1111
use tokio::net::TcpListener;
1212

13+
// This would normally come from the `hyper-util` crate, but we can't depend
14+
// on that here because it would be a cyclical dependency.
1315
#[path = "../benches/support/mod.rs"]
1416
mod support;
15-
use support::TokioIo;
17+
use support::{TokioIo, TokioTimer};
1618

1719
// An async function that consumes a request, does nothing with it and returns a
1820
// response.
19-
async fn hello(_: Request<hyper::body::Incoming>) -> Result<Response<Full<Bytes>>, Infallible> {
21+
async fn hello(_: Request<impl hyper::body::Body>) -> Result<Response<Full<Bytes>>, Infallible> {
2022
Ok(Response::new(Full::new(Bytes::from("Hello World!"))))
2123
}
2224

@@ -51,6 +53,7 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5153
// Handle the connection from the client using HTTP1 and pass any
5254
// HTTP requests received on that connection to the `hello` function
5355
if let Err(err) = http1::Builder::new()
56+
.timer(TokioTimer)
5457
.serve_connection(io, service_fn(hello))
5558
.await
5659
{

0 commit comments

Comments
 (0)