Browse Source

Update the various Rust programs.

Steve Klabnik 9 năm trước cách đây
mục cha
commit
9cc5353be9

+ 1 - 2
frameworks/Rust/hyper/Cargo.toml

@@ -4,5 +4,4 @@ version = "0.1.0"
 authors = ["Steve Klabnik <[email protected]>"]
 
 [dependencies]
-
-hyper="0.5.2"
+hyper="0.7.2"

+ 12 - 12
frameworks/Rust/hyper/src/main.rs

@@ -1,24 +1,24 @@
 extern crate hyper;
 
 use hyper::server::{Server, Request, Response};
-use hyper::status::StatusCode;
 use hyper::uri::RequestUri;
 use hyper::header::ContentType;
-use hyper::header::ContentLength;
 use hyper::header;
 
 const HELLO_WORLD: &'static [u8; 14] = b"Hello, World!\n";
 
 fn main() {
-    Server::http(|req: Request, mut res: Response| {
-        match (req.method, req.uri) {
-            (hyper::Get, RequestUri::AbsolutePath(ref path)) if path == "/plaintext" => {
-                res.headers_mut().set(ContentType::plaintext());
-                res.headers_mut().set(header::Server("Hyper".to_owned()));
+    Server::http("0.0.0.0:8080").unwrap().handle(handler).unwrap();
+}
+
+fn handler(req: Request, mut res: Response) {
+    match (req.method, req.uri) {
+        (hyper::Get, RequestUri::AbsolutePath(ref path)) if path == "/plaintext" => {
+            res.headers_mut().set(ContentType::plaintext());
+            res.headers_mut().set(header::Server("Hyper".to_owned()));
 
-                res.send(HELLO_WORLD).unwrap();
-            }
-            _ => (),
-        };
-    }).listen("0.0.0.0:8080").unwrap();
+            res.send(HELLO_WORLD).unwrap();
+        }
+        _ => (),
+    };
 }

+ 3 - 3
frameworks/Rust/iron/Cargo.toml

@@ -4,6 +4,6 @@ name = "iron"
 version = "0.0.1"
 
 [dependencies]
-rustc-serialize = "0.3"
-iron = "0.1.18"
-router = "0.0.10"
+rustc-serialize = "0.3.18"
+iron = "0.2.6"
+router = "0.1.0"

+ 2 - 2
frameworks/Rust/nickel/Cargo.toml

@@ -4,6 +4,6 @@ name = "nickel"
 version = "0.0.1"
 
 [dependencies]
-rustc-serialize = "0.3"
-nickel = "0.5.0"
+rustc-serialize = "0.3.18"
+nickel = "0.7.3"
 nickel_macros = "0.1.0"