diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 816bebc..b6255d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,22 @@ mod barbfile; +use jsonformat::{format_json, Indentation}; + use std::fs; +use std::str::FromStr; use ureq; fn main() { - let barbfile = fs::read_to_string("test.barb").expect("Failed to read file"); - ureq::get("https://api.met.no/weatherapi/tafmetar/1.0/tafmetar?icao=EGKK"); + let bfile = barbfile::BarbFile::from_str( + fs::read_to_string("test.barb") + .expect("Failed to read file") + .as_str(), + ) + .expect("Failed to parse file"); + let result = ureq::request(bfile.method_as_string().as_str(), &bfile.url()) + .call() + .unwrap() + .into_string() + .unwrap(); + println!("{}", format_json(result.as_str(), Indentation::Default)); } |