Browse Source

Rust/hyper: Update hyper to 0.11 and mime to 0.3 (#2865)

Robin Stocker 8 years ago
parent
commit
44b2238880
2 changed files with 6 additions and 10 deletions
  1. 2 5
      frameworks/Rust/hyper/Cargo.toml
  2. 4 5
      frameworks/Rust/hyper/src/main.rs

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

@@ -5,14 +5,11 @@ authors = ["Steve Klabnik <[email protected]>", "Alexander Polyakov <plhk@s
 
 [dependencies]
 futures = "0.1"
+hyper = "0.11"
 tokio-proto = "0.1"
 tokio-service = "0.1"
 num_cpus = "1.2"
 serde = "1.0"
 serde_json = "1.0"
 serde_derive = "1.0"
-mime = "0.2"
-
-[dependencies.hyper]
-git = "https://github.com/hyperium/hyper/"
-rev = "acd62cda446e4c647716a2d595342360dc24a080"
+mime = "0.3"

+ 4 - 5
frameworks/Rust/hyper/src/main.rs

@@ -6,14 +6,13 @@ extern crate hyper;
 extern crate serde_derive;
 extern crate serde_json;
 extern crate num_cpus;
-#[macro_use]
 extern crate mime;
 
 use tokio_proto::TcpServer;
 use futures::future;
 use hyper::Method::Get;
 use hyper::header::{ContentLength, ContentType, Server};
-use hyper::status::StatusCode::NotFound;
+use hyper::StatusCode::NotFound;
 use hyper::server::{Http, Service, Request, Response};
 use std::net::SocketAddr;
 
@@ -37,7 +36,7 @@ impl Service for TechEmpower {
             (&Get, "/plaintext") => {
                 Response::new()
                     .with_header(ContentLength(HELLOWORLD.len() as u64))
-                    .with_header(ContentType(mime!(Text / Plain)))
+                    .with_header(ContentType(mime::TEXT_PLAIN))
                     .with_body(HELLOWORLD)
             }
             (&Get, "/json") => {
@@ -45,7 +44,7 @@ impl Service for TechEmpower {
                 let rep_body = serde_json::to_vec(&rep).unwrap();
                 Response::new()
                     .with_header(ContentLength(rep_body.len() as u64))
-                    .with_header(ContentType(mime!(Application / Json)))
+                    .with_header(ContentType(mime::APPLICATION_JSON))
                     .with_body(rep_body)
             }
             _ => Response::new().with_status(NotFound),
@@ -63,4 +62,4 @@ fn main() {
 
     srv.threads(num_cpus::get());
     srv.serve(move || Ok(TechEmpower))
-}
+}