From 37bd5e5da26887b9fceb34b46b3df4b577f7a1e1 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:32:43 +0900 Subject: [PATCH] Update flexible-responders --- examples/flexible-responders/Cargo.toml | 3 ++- examples/flexible-responders/src/main.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/flexible-responders/Cargo.toml b/examples/flexible-responders/Cargo.toml index 5aec859..8a29135 100644 --- a/examples/flexible-responders/Cargo.toml +++ b/examples/flexible-responders/Cargo.toml @@ -4,5 +4,6 @@ version = "1.0.0" edition = "2018" [dependencies] -actix-web = "1.0" +actix-web = "2.0" +actix-rt = "1.0" serde = "1.0" diff --git a/examples/flexible-responders/src/main.rs b/examples/flexible-responders/src/main.rs index fd56f1e..0237fc3 100644 --- a/examples/flexible-responders/src/main.rs +++ b/examples/flexible-responders/src/main.rs @@ -7,23 +7,23 @@ struct Measurement { temperature: f32, } -fn hello_world() -> impl Responder { +async fn hello_world() -> impl Responder { "Hello World!" } -fn current_temperature() -> impl Responder { +async fn current_temperature() -> impl Responder { web::Json(Measurement { temperature: 42.3 }) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(web::resource("/").to(hello_world)) .service(web::resource("/temp").to(current_temperature)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } //