Skip to content

Commit b0e8a8d

Browse files
committed
Update request-routing
1 parent cc2a7a0 commit b0e8a8d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

examples/request-routing/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ version = "1.0.0"
44
edition = "2018"
55

66
[dependencies]
7-
actix-web = "1.0"
7+
actix-web = "2.0"
8+
actix-rt = "1.0"
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
// <request-routing>
22
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
33

4-
fn index(_req: HttpRequest) -> impl Responder {
4+
async fn index(_req: HttpRequest) -> impl Responder {
55
"Hello from the index page."
66
}
77

8-
fn hello(path: web::Path<String>) -> impl Responder {
8+
async fn hello(path: web::Path<String>) -> impl Responder {
99
format!("Hello {}!", &path)
1010
}
1111

12-
fn main() {
12+
#[actix_rt::main]
13+
async fn main() -> std::io::Result<()> {
1314
HttpServer::new(|| {
1415
App::new()
1516
.service(web::resource("/").to(index))
1617
.service(web::resource("/{name}").to(hello))
1718
})
18-
.bind("127.0.0.1:8088")
19-
.unwrap()
19+
.bind("127.0.0.1:8088")?
2020
.run()
21-
.unwrap();
21+
.await
2222
}
2323
// </request-routing>

0 commit comments

Comments
 (0)