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 num_cpus; | ||||
|  | ||||
| use futures::future::FutureResult; | ||||
|  | ||||
| use hyper::header::{ContentLength, ContentType}; | ||||
| use hyper::server::{Http, Service, Request, Response}; | ||||
|  | ||||
| @@ -16,9 +18,9 @@ impl Service for Hello { | ||||
|     type Request = Request; | ||||
|     type Response = Response; | ||||
|     type Error = hyper::Error; | ||||
|     type Future = ::futures::Finished<Response, hyper::Error>; | ||||
|     type Future = FutureResult<Response, hyper::Error>; | ||||
|     fn call(&self, _req: Request) -> Self::Future { | ||||
|         ::futures::finished( | ||||
|         futures::future::ok( | ||||
|             Response::new() | ||||
|                 .with_header(ContentLength(PHRASE.len() as u64)) | ||||
|                 .with_header(ContentType::plaintext()) | ||||
|   | ||||
| @@ -3,6 +3,8 @@ extern crate futures; | ||||
| extern crate hyper; | ||||
| extern crate pretty_env_logger; | ||||
|  | ||||
| use futures::future::FutureResult; | ||||
|  | ||||
| use hyper::{Get, Post, StatusCode}; | ||||
| use hyper::header::ContentLength; | ||||
| use hyper::server::{Http, Service, Request, Response}; | ||||
| @@ -16,10 +18,10 @@ impl Service for Echo { | ||||
|     type Request = Request; | ||||
|     type Response = Response; | ||||
|     type Error = hyper::Error; | ||||
|     type Future = ::futures::Finished<Response, hyper::Error>; | ||||
|     type Future = FutureResult<Response, hyper::Error>; | ||||
|  | ||||
|     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") => { | ||||
|                 Response::new() | ||||
|                     .with_header(ContentLength(INDEX.len() as u64)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user