Browse Source

warp-rust 0.2 (#5407)

Konrad Borowski 5 years ago
parent
commit
9e1fba6d13

+ 2 - 1
frameworks/Rust/warp-rust/Cargo.toml

@@ -6,4 +6,5 @@ edition = "2018"
 
 [dependencies]
 serde = { version = "1.0.103", features = ["derive"] }
-warp = "0.1.20"
+tokio = { version = "0.2.9", features = ["macros"] }
+warp = "0.2.0"

+ 1 - 1
frameworks/Rust/warp-rust/README.md

@@ -2,7 +2,7 @@
 
 warp is a composable web server framework based on hyper.
 
-* [API Documentation](https://docs.rs/warp/0.1)
+* [API Documentation](https://docs.rs/warp/0.2)
 
 ### Test Type Implementation Source Code
 

+ 5 - 4
frameworks/Rust/warp-rust/src/main.rs

@@ -7,15 +7,16 @@ struct Message {
     message: &'static str,
 }
 
-fn main() {
-    let json = warp::path("json").map(|| {
+#[tokio::main]
+async fn main() {
+    let json = warp::path!("json").map(|| {
         warp::reply::json(&Message {
             message: "Hello, world!",
         })
     });
-    let plaintext = warp::path("plaintext").map(|| "Hello, World!");
+    let plaintext = warp::path!("plaintext").map(|| "Hello, World!");
     let routes = json
         .or(plaintext)
         .map(|reply| warp::reply::with_header(reply, header::SERVER, "warp"));
-    warp::serve(routes).run(([0, 0, 0, 0], 8080))
+    warp::serve(routes).run(([0, 0, 0, 0], 8080)).await;
 }