diff options
author | Teddy Wing | 2021-05-30 19:20:08 +0200 |
---|---|---|
committer | Teddy Wing | 2021-05-30 19:20:08 +0200 |
commit | 7c046b3e9531b9dd71df06ef7381f9ccc086d1a7 (patch) | |
tree | 6045014b025acd4f8f22712eb724517588ca5e23 | |
parent | a340db978034715823eaadd005d2627815aed4ea (diff) | |
download | reflectub-7c046b3e9531b9dd71df06ef7381f9ccc086d1a7.tar.bz2 |
github::fetch_repos(): Extract username to function argument
-rw-r--r-- | src/github.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/github.rs b/src/github.rs index 0f4de77..bcd9865 100644 --- a/src/github.rs +++ b/src/github.rs @@ -42,7 +42,7 @@ impl Repo { /// Fetch all GitHub repositories for the given user. -pub async fn fetch_repos() -> Result<Vec<Repo>, Error> { +pub async fn fetch_repos(github_username: &str) -> Result<Vec<Repo>, Error> { let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Accept", "application/vnd.github.v3+json".parse()?); @@ -58,7 +58,7 @@ pub async fn fetch_repos() -> Result<Vec<Repo>, Error> { reqwest::Method::GET, format!( "https://api.github.com/users/{}/repos?page={}&per_page=100", - "teddywing", + github_username, i, ), ) diff --git a/src/main.rs b/src/main.rs index 77083cf..9689d3c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use std::path::{Path, PathBuf}; #[tokio::main] async fn main() { - let repos = github::fetch_repos().await.unwrap(); + let repos = github::fetch_repos("teddywing").await.unwrap(); dbg!(&repos); |