feat(lib): convert to use tokio 0.1

BREAKING CHANGE: All uses of `Handle` now need to be new-tokio `Handle`.

Co-authored-by: Sean McArthur <sean@seanmonstar.com>
This commit is contained in:
Sam Reis
2018-03-15 10:46:03 +11:00
committed by Sean McArthur
parent 8c52c2dfd3
commit 27b8db3af8
23 changed files with 680 additions and 505 deletions

View File

@@ -2,6 +2,10 @@
extern crate hyper;
extern crate futures;
extern crate pretty_env_logger;
extern crate tokio;
use futures::Future;
use futures::future::lazy;
use hyper::{Body, Response};
use hyper::server::{Http, const_service, service_fn};
@@ -16,10 +20,13 @@ fn main() {
Ok(Response::new(Body::from(PHRASE)))
}));
let server = Http::new()
.sleep_on_errors(true)
.bind(&addr, new_service)
.unwrap();
println!("Listening on http://{} with 1 thread.", server.local_addr().unwrap());
server.run().unwrap();
tokio::run(lazy(move || {
let server = Http::new()
.sleep_on_errors(true)
.bind(&addr, new_service)
.unwrap();
println!("Listening on http://{} with 1 thread.", server.local_addr().unwrap());
server.run().map_err(|err| eprintln!("Server error {}", err))
}));
}