From 94c8c843b165099853c84c5fff94e9812633397e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 29 Dec 2019 01:38:51 +0900 Subject: [PATCH] Update main-example --- examples/main-example/Cargo.toml | 3 ++- examples/main-example/src/main.rs | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/main-example/Cargo.toml b/examples/main-example/Cargo.toml index 03e0327..10e38ec 100644 --- a/examples/main-example/Cargo.toml +++ b/examples/main-example/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/main-example/src/main.rs b/examples/main-example/src/main.rs index 11f7025..004ec57 100644 --- a/examples/main-example/src/main.rs +++ b/examples/main-example/src/main.rs @@ -1,20 +1,20 @@ // use actix_web::{web, App, HttpRequest, HttpServer, Responder}; -fn greet(req: HttpRequest) -> impl Responder { +async fn greet(req: HttpRequest) -> impl Responder { let name = req.match_info().get("name").unwrap_or("World"); format!("Hello {}!", &name) } -fn main() { +#[actix_rt::main] +async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(greet)) .route("/{name}", web::get().to(greet)) }) - .bind("127.0.0.1:8088") - .unwrap() + .bind("127.0.0.1:8088")? .run() - .unwrap(); + .await } //