feat: connect to github step

This commit is contained in:
2026-04-25 00:49:50 +01:00
parent a9f4d1d923
commit a54cc84660
12 changed files with 450 additions and 122 deletions

View File

@@ -58,6 +58,7 @@ impl QueryContext {
.request(method, format!("{}{}", self.github.base_url, url))
.header("Accept", "application/vnd.github+json")
.header("X-GitHub-Api-Version", "2026-03-10")
.header("User-Agent", "kennethnym")
.bearer_auth(&auth.access_token))
}
}
@@ -83,11 +84,19 @@ where
let status = res.status().clone();
let data = res.bytes().await?;
println!("[query] RES {:?} {:?}", status, str::from_utf8(&data));
if status.is_success() {
serde_json::from_slice::<T>(&data).map_err(|e| e.into())
} else {
serde_json::from_slice::<GithubError>(&data)
.map_err(|e| e.into())
.and_then(|e| Err(Error::Github(e)))
.and_then(|e| {
println!(
"[api parse error] invalid json, received: {:?}",
str::from_utf8(&data),
);
Err(Error::Github(e))
})
}
}