MCPcopy Create free account
hub / github.com/1jehuang/jcode / github_api_request

Function github_api_request

crates/jcode-app-core/src/update.rs:243–261  ·  view source on GitHub ↗
(
    client: &reqwest::blocking::Client,
    url: &str,
)

Source from the content-addressed store, hash-verified

241}
242
243fn github_api_request(
244 client: &reqwest::blocking::Client,
245 url: &str,
246) -> reqwest::blocking::RequestBuilder {
247 let request = client
248 .get(url)
249 .header(reqwest::header::ACCEPT, "application/vnd.github+json")
250 .header("X-GitHub-Api-Version", "2022-11-28");
251
252 // Authenticated requests use the user's 5000 req/h quota instead of the
253 // shared unauthenticated 60 req/h per-IP bucket, which other tools on the
254 // same machine or NAT can exhaust and cause spurious 403s on update
255 // checks. Falls back to unauthenticated when no token is available.
256 if let Some(token) = jcode_base::github::github_public_api_token() {
257 request.bearer_auth(token)
258 } else {
259 request
260 }
261}
262
263fn latest_main_sha_blocking() -> Result<String> {
264 let url = format!("https://api.github.com/repos/{}/commits/main", GITHUB_REPO);

Callers 2

latest_main_sha_blockingFunction · 0.85

Calls 3

github_public_api_tokenFunction · 0.85
headerMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected