소스 검색

warp-rust 0.2 (#5407)

Konrad Borowski 5 년 전
부모
커밋
9e1fba6d13
3개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 1
      frameworks/Rust/warp-rust/Cargo.toml
  2. 1 1
      frameworks/Rust/warp-rust/README.md
  3. 5 4
      frameworks/Rust/warp-rust/src/main.rs

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

@@ -6,4 +6,5 @@ edition = "2018"
 
 
 [dependencies]
 [dependencies]
 serde = { version = "1.0.103", features = ["derive"] }
 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.
 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
 ### Test Type Implementation Source Code
 
 

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

@@ -7,15 +7,16 @@ struct Message {
     message: &'static str,
     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 {
         warp::reply::json(&Message {
             message: "Hello, world!",
             message: "Hello, world!",
         })
         })
     });
     });
-    let plaintext = warp::path("plaintext").map(|| "Hello, World!");
+    let plaintext = warp::path!("plaintext").map(|| "Hello, World!");
     let routes = json
     let routes = json
         .or(plaintext)
         .or(plaintext)
         .map(|reply| warp::reply::with_header(reply, header::SERVER, "warp"));
         .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;
 }
 }