aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-05-29 16:37:09 +0200
committerTeddy Wing2021-05-29 16:37:09 +0200
commit33a08a9159379588871442672f7c7362ba352501 (patch)
tree2a32f54416051ce4d924afad8bda7bf7e2fa46a2 /src/main.rs
parent1a9a3ecf18cd71898be230e2045b2d907f8fcdd7 (diff)
downloadreflectub-33a08a9159379588871442672f7c7362ba352501.tar.bz2
Split GitHub API request into separate files
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs45
1 files changed, 3 insertions, 42 deletions
diff --git a/src/main.rs b/src/main.rs
index 14d5f4d..ea540e6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,47 +1,8 @@
-use reqwest::blocking::ClientBuilder;
-use serde::Deserialize;
-
-
-const USER_AGENT: &'static str = concat!(
- env!("CARGO_PKG_NAME"),
- "/",
- env!("CARGO_PKG_VERSION"),
-);
-
-
-#[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?
-}
+use reflectub::github;
fn main() {
- let mut headers = reqwest::header::HeaderMap::new();
- headers.insert("Accept", "application/vnd.github.v3+json".parse().unwrap());
-
- let client = ClientBuilder::new()
- .user_agent(USER_AGENT)
- .default_headers(headers)
- .build()
- .unwrap();
-
- let response = client.request(
- reqwest::Method::GET,
- format!(
- "https://api.github.com/users/{}/repos",
- "teddywing",
- ),
- )
- .send()
- .unwrap()
- .json::<Vec<Repo>>()
- .unwrap();
+ let repos = github::fetch_repos().unwrap();
- dbg!(&response);
+ dbg!(&repos);
}