INNER CODE UNIT · Rust
get_plugins_from_url
Drew-Alleman/DataSurgeon · src/plugins/mod.rs:88
pub fn get_plugins_from_url(url: &str) -> Result<Vec<RegexPlugin>, Box<dyn std::error::Error>> {
let client = reqwest::blocking::Client::builder()
.user_agent("Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; MAGWJS; rv:11.0) like Gecko")
.build()?;
let resp = client.get(url).send()?;
if !resp.status().is_success() {
println!("Error: Received a {} status code from the server.", resp.status());
std::process::exit(1);
}
let body = resp.text()?;
let plugins: Vec<RegexPlugin> = serde_json::from_str(&body)?;
Ok(plugins)
}