From b4e2750d6af5f2bffe547c864f71b3f5a9f3706a Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sun, 6 Jun 2021 15:26:33 +0200 Subject: [PATCH] Tweak hello world example --- README.md | 8 +++----- src/lib.rs | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3972b91b..2594ed0c 100644 --- a/README.md +++ b/README.md @@ -34,17 +34,15 @@ use tower::make::Shared; #[tokio::main] async fn main() { // build our application with a single route - let app = route("/", get(handler)); + let app = route("/", get(|request: Request| async { + "Hello, World!" + })); // run it with hyper on localhost:3000 let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); let server = Server::bind(&addr).serve(Shared::new(app)); server.await.unwrap(); } - -async fn handler(req: Request) -> &'static str { - "Hello, World!" -} ``` ## Routing diff --git a/src/lib.rs b/src/lib.rs index 2196c811..e179f879 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,17 +32,15 @@ //! #[tokio::main] //! async fn main() { //! // build our application with a single route -//! let app = route("/", get(handler)); +//! let app = route("/", get(|request: Request| async { +//! "Hello, World!" +//! })); //! //! // run it with hyper on localhost:3000 //! let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); //! let server = Server::bind(&addr).serve(Shared::new(app)); //! server.await.unwrap(); //! } -//! -//! async fn handler(req: Request) -> &'static str { -//! "Hello, World!" -//! } //! ``` //! //! # Routing