diff --git a/examples/request-routing/Cargo.toml b/examples/request-routing/Cargo.toml index cdef3e6..df5d1d7 100644 --- a/examples/request-routing/Cargo.toml +++ b/examples/request-routing/Cargo.toml @@ -4,4 +4,5 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/request-routing/src/main.rs b/examples/request-routing/src/main.rs index 8a20019..4e9694a 100644 --- a/examples/request-routing/src/main.rs +++ b/examples/request-routing/src/main.rs @@ -1,23 +1,23 @@ // use actix_web::{web, App, HttpRequest, HttpServer, Responder}; -fn index(_req: HttpRequest) -> impl Responder { +async fn index(_req: HttpRequest) -> impl Responder { "Hello from the index page." } -fn hello(path: web::Path) -> impl Responder { +async fn hello(path: web::Path) -> impl Responder { format!("Hello {}!", &path) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(web::resource("/").to(index)) .service(web::resource("/{name}").to(hello)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } //