From 42b945b7289d8e36900074327a811a50f8cc5e15 Mon Sep 17 00:00:00 2001 From: Guillaume Pasquet Date: Tue, 16 Nov 2021 22:36:42 +0000 Subject: Working actual queries and basic JSON formatting. No error handling. --- src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/main.rs') 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)); } -- cgit v1.2.3