Created
February 7, 2018 23:36
-
-
Save seanmonstar/bb7162533e0fdeb37654ed7e204fac1b to your computer and use it in GitHub Desktop.
hyper v0.12 client example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate hyper; | |
extern crate tokio; | |
use tokio::executor::current_thread; | |
fn main() { | |
// uses default Handle, the global loop | |
let client = hyper::Client::new(); | |
current_thread::run(|_| { | |
let fut = client.get("https://hyper.rs") | |
.and_then(|res| { | |
let (_, body) = res.into_parts(); | |
body.concat() | |
}) | |
.map(|_bytes| { | |
// do whatever? | |
}) | |
.map_err(|e| eprintln!("http error: {}", e)); | |
current_thread::spawn(fut); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment