2018-09-25 11:27:28 +02:00
|
|
|
extern crate hyper;
|
2018-09-24 15:45:32 +02:00
|
|
|
|
2018-09-25 11:27:28 +02:00
|
|
|
use std::env;
|
2018-09-24 15:45:32 +02:00
|
|
|
use std::process::exit;
|
|
|
|
|
2018-09-25 11:27:28 +02:00
|
|
|
use hyper::Client;
|
|
|
|
use hyper::rt::{self, Future};
|
2018-09-24 15:45:32 +02:00
|
|
|
|
2018-09-24 13:52:45 +02:00
|
|
|
fn main() {
|
2018-09-24 15:45:32 +02:00
|
|
|
|
2018-09-25 11:27:28 +02:00
|
|
|
let current_dir = match env::current_dir() {
|
|
|
|
Err(e) => {
|
|
|
|
eprintln!("Couldn't find current directory: {:?}", e);
|
|
|
|
exit(1);
|
|
|
|
},
|
|
|
|
Ok(path) => {
|
|
|
|
let p = path.to_str();
|
|
|
|
p.unwrap().to_owned()
|
|
|
|
},
|
|
|
|
};
|
2018-09-24 15:45:32 +02:00
|
|
|
|
2018-09-25 11:27:28 +02:00
|
|
|
let url = format!("http://localhost:1500{}", current_dir);
|
|
|
|
let url = url.parse::<hyper::Uri>().unwrap();
|
|
|
|
rt::run(fetch_url(url));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fetch_url(url: hyper::Uri) -> impl Future<Item=(), Error=()> {
|
|
|
|
let client = Client::new();
|
|
|
|
|
|
|
|
client.get(url)
|
|
|
|
.map(|_| ())
|
|
|
|
// If there was an error, let the user know...
|
|
|
|
.map_err(|err| {
|
|
|
|
eprintln!("Error {}", err);
|
|
|
|
})
|
2018-09-24 13:52:45 +02:00
|
|
|
}
|