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:
@@ -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))
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user