diff --git a/examples/getting-started/Cargo.toml b/examples/getting-started/Cargo.toml index 1632b62..fee4ef7 100644 --- a/examples/getting-started/Cargo.toml +++ b/examples/getting-started/Cargo.toml @@ -5,4 +5,5 @@ edition = "2018" workspace = "../" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" diff --git a/examples/getting-started/src/main.rs b/examples/getting-started/src/main.rs index 8208bae..107788b 100644 --- a/examples/getting-started/src/main.rs +++ b/examples/getting-started/src/main.rs @@ -1,11 +1,11 @@ // use actix_web::{web, App, HttpResponse, HttpServer, Responder}; -fn index() -> impl Responder { +async fn index() -> impl Responder { HttpResponse::Ok().body("Hello world!") } -fn index2() -> impl Responder { +async fn index2() -> impl Responder { HttpResponse::Ok().body("Hello world again!") } // @@ -14,21 +14,21 @@ fn index2() -> impl Responder { use actix_web::get; #[get("/hello")] -fn index3() -> impl Responder { +async fn index3() -> impl Responder { HttpResponse::Ok().body("Hey there!") } // //
-fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(index)) .route("/again", web::get().to(index2)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } //