aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-05-29 14:39:29 +0200
committerTeddy Wing2021-05-29 14:39:29 +0200
commit1a9a3ecf18cd71898be230e2045b2d907f8fcdd7 (patch)
tree5bbd6363aa0671fb3326b30ca5f349d12e9e8091 /src/main.rs
parenta1f45240d3d0353028fc429175479adce5a15b2d (diff)
downloadreflectub-1a9a3ecf18cd71898be230e2045b2d907f8fcdd7.tar.bz2
Parse GitHub API response to a struct
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 5edbf17..14d5f4d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
use reqwest::blocking::ClientBuilder;
+use serde::Deserialize;
const USER_AGENT: &'static str = concat!(
@@ -8,6 +9,18 @@ const USER_AGENT: &'static str = concat!(
);
+#[derive(Debug, Deserialize)]
+struct Repo {
+ id: usize,
+ name: String,
+ description: Option<String>,
+ fork: bool,
+ git_url: String,
+ default_branch: String,
+ updated_at: String, // TODO: Maybe parse to date?
+}
+
+
fn main() {
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Accept", "application/vnd.github.v3+json".parse().unwrap());
@@ -26,6 +39,8 @@ fn main() {
),
)
.send()
+ .unwrap()
+ .json::<Vec<Repo>>()
.unwrap();
dbg!(&response);