1mod error;
2
3use error::Error;
4use mantid_core::Boxed;
5
6use reqwest::Client;
7use tokio::runtime::Runtime;
8
9pub async fn get(uri: &str, headers: &bool) -> Result<(), Error> {
10 let client = Client::new();
11 let res = client.get(uri).send().await?;
12 if *headers {
13 for (key, value) in res.headers().iter() {
14 println!("{}: {}", key, value.to_str()?);
15 }
16 } else {
17 print!("{}", res.text().await?);
18 }
19 Ok(())
20}
21
22pub fn http_cli(uri: &str, headers: &bool) -> Boxed {
23 let rt = Runtime::new()?;
24 Ok(rt.block_on(get(uri, headers))?)
25}