Merge pull request #1052 from ericchiang/futures-example
refactor(examples): remove use of depricated futures features
This commit is contained in:
		| @@ -4,6 +4,8 @@ extern crate futures; | |||||||
| extern crate pretty_env_logger; | extern crate pretty_env_logger; | ||||||
| //extern crate num_cpus; | //extern crate num_cpus; | ||||||
|  |  | ||||||
|  | use futures::future::FutureResult; | ||||||
|  |  | ||||||
| use hyper::header::{ContentLength, ContentType}; | use hyper::header::{ContentLength, ContentType}; | ||||||
| use hyper::server::{Http, Service, Request, Response}; | use hyper::server::{Http, Service, Request, Response}; | ||||||
|  |  | ||||||
| @@ -16,9 +18,9 @@ impl Service for Hello { | |||||||
|     type Request = Request; |     type Request = Request; | ||||||
|     type Response = Response; |     type Response = Response; | ||||||
|     type Error = hyper::Error; |     type Error = hyper::Error; | ||||||
|     type Future = ::futures::Finished<Response, hyper::Error>; |     type Future = FutureResult<Response, hyper::Error>; | ||||||
|     fn call(&self, _req: Request) -> Self::Future { |     fn call(&self, _req: Request) -> Self::Future { | ||||||
|         ::futures::finished( |         futures::future::ok( | ||||||
|             Response::new() |             Response::new() | ||||||
|                 .with_header(ContentLength(PHRASE.len() as u64)) |                 .with_header(ContentLength(PHRASE.len() as u64)) | ||||||
|                 .with_header(ContentType::plaintext()) |                 .with_header(ContentType::plaintext()) | ||||||
|   | |||||||
| @@ -3,6 +3,8 @@ extern crate futures; | |||||||
| extern crate hyper; | extern crate hyper; | ||||||
| extern crate pretty_env_logger; | extern crate pretty_env_logger; | ||||||
|  |  | ||||||
|  | use futures::future::FutureResult; | ||||||
|  |  | ||||||
| use hyper::{Get, Post, StatusCode}; | use hyper::{Get, Post, StatusCode}; | ||||||
| use hyper::header::ContentLength; | use hyper::header::ContentLength; | ||||||
| use hyper::server::{Http, Service, Request, Response}; | use hyper::server::{Http, Service, Request, Response}; | ||||||
| @@ -16,10 +18,10 @@ impl Service for Echo { | |||||||
|     type Request = Request; |     type Request = Request; | ||||||
|     type Response = Response; |     type Response = Response; | ||||||
|     type Error = hyper::Error; |     type Error = hyper::Error; | ||||||
|     type Future = ::futures::Finished<Response, hyper::Error>; |     type Future = FutureResult<Response, hyper::Error>; | ||||||
|  |  | ||||||
|     fn call(&self, req: Request) -> Self::Future { |     fn call(&self, req: Request) -> Self::Future { | ||||||
|         ::futures::finished(match (req.method(), req.path()) { |         futures::future::ok(match (req.method(), req.path()) { | ||||||
|             (&Get, "/") | (&Get, "/echo") => { |             (&Get, "/") | (&Get, "/echo") => { | ||||||
|                 Response::new() |                 Response::new() | ||||||
|                     .with_header(ContentLength(INDEX.len() as u64)) |                     .with_header(ContentLength(INDEX.len() as u64)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user