1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use reqwest::blocking::Client;
use reqwest::header;
use http::header::ACCEPT;
mod alerts;
mod glossary;
#[derive(Debug)]
pub struct NwsClient {
host: String,
client: Client
}
impl NwsClient {
#[allow(dead_code)]
fn new(user_agent: Option<String>) -> NwsClient {
let mut headers = header::HeaderMap::new();
headers.insert(ACCEPT, "application/geo+json".parse().unwrap());
let default_user_agent = match user_agent {
Some(u) => u,
None => String::from("nws-rust-implementation"),
};
let client: Client = reqwest::blocking::Client::builder()
.user_agent(&default_user_agent)
.default_headers(headers)
.build().unwrap();
NwsClient{ host: String::from("https://api.weather.gov"), client }
}
}