Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions crates/crates_io_github/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,24 @@ impl RealGitHubClient {
T: DeserializeOwned,
{
let url = format!("https://api.github.com{url}");
info!("GITHUB HTTP: {url}");
info!("GitHub request: GET {url}");

self.client
let response = self
.client
.get(&url)
.header(header::ACCEPT, "application/vnd.github.v3+json")
.header(header::AUTHORIZATION, auth)
.header(header::USER_AGENT, "crates.io (https://crates.io)")
.send()
.await?
.error_for_status()?
.json()
.await
.map_err(Into::into)
.error_for_status()?;

let headers = response.headers();
let remaining = headers.get("x-ratelimit-remaining");
let limit = headers.get("x-ratelimit-limit");
debug!("GitHub rate limit remaining: {remaining:?}/{limit:?}");

response.json().await.map_err(Into::into)
}

/// Sends a GET to GitHub using OAuth access token authentication
Expand Down