mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-22 07:08:16 +01:00
Tweak hello world example
This commit is contained in:
parent
35ab973acb
commit
b4e2750d6a
2 changed files with 6 additions and 10 deletions
|
@ -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<Body>| 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<Body>) -> &'static str {
|
||||
"Hello, World!"
|
||||
}
|
||||
```
|
||||
|
||||
## Routing
|
||||
|
|
|
@ -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<Body>| 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<Body>) -> &'static str {
|
||||
//! "Hello, World!"
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! # Routing
|
||||
|
|
Loading…
Reference in a new issue