From 6684075cc5d7fc392ae46da966916ecb64293f89 Mon Sep 17 00:00:00 2001 From: Jared Burce Date: Wed, 18 Mar 2020 13:29:35 -0700 Subject: [PATCH] use tokio::main macro --- Cargo.toml | 6 +++--- src/main.rs | 19 +++++++------------ static/index.html | 1 + 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1b678fb..49540df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Jared Burce "] edition = "2018" [dependencies] -warp = "0.2" -webrtc-unreliable = "0.4" -tokio = "0.2" futures = "0.3" pretty_env_logger = "0.4" +tokio = { version = "0.2", features = ["macros"] } +warp = "0.2" +webrtc-unreliable = "0.4" diff --git a/src/main.rs b/src/main.rs index d06007a..d0c95ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,14 @@ -// use tokio::prelude::*; use warp::Filter; -fn main() -> Result<(), Box> { +#[tokio::main(basic_scheduler)] +async fn main() { pretty_env_logger::init(); - let mut rt = tokio::runtime::Runtime::new()?; - rt.block_on(async { - let root = warp::get() - .and(warp::path::end()) - .and(warp::fs::file("./static/index.html")); + let root = warp::get() + .and(warp::path::end()) + .and(warp::fs::file("./static/index.html")); - let routes = root; + let routes = root; - warp::serve(routes).run(([127, 0, 0, 1], 8060)).await; - }); - - Ok(()) + warp::serve(routes).run(([127, 0, 0, 1], 8060)).await; } diff --git a/static/index.html b/static/index.html index bbaaf9a..aef9406 100644 --- a/static/index.html +++ b/static/index.html @@ -1,3 +1,4 @@ + Hello, World!