Skip to content

Commit

Permalink
Add accept application/vnd.github+json to GitHub rest requests
Browse files Browse the repository at this point in the history
  • Loading branch information
russellbanks committed Aug 27, 2024
1 parent 2152829 commit 0b1aa38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/github/github_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::github::graphql::merge_upstream::{MergeUpstream, MergeUpstreamVariabl
use crate::github::graphql::types::{GitObjectId, GitRefName};
use crate::github::graphql::update_refs::{RefUpdate, UpdateRefs, UpdateRefsVariables};
use crate::github::rest::get_tree::GitTree;
use crate::github::rest::GITHUB_JSON_MIME;
use crate::github::utils::{get_package_path, is_manifest_file};
use crate::manifests::default_locale_manifest::DefaultLocaleManifest;
use crate::manifests::installer_manifest::InstallerManifest;
Expand All @@ -51,6 +52,7 @@ use cynic::http::ReqwestExt;
use cynic::{Id, MutationBuilder, QueryBuilder};
use indexmap::IndexMap;
use itertools::Itertools;
use reqwest::header::ACCEPT;
use reqwest::Client;
use std::collections::BTreeSet;
use std::env;
Expand Down Expand Up @@ -121,7 +123,13 @@ impl GitHub {
let endpoint = format!(
"https://api.github.com/repos/{owner}/{repo}/git/trees/HEAD:{path}?recursive=true"
);
let response = client.get(endpoint).send().await?.json::<GitTree>().await?;
let response = client
.get(endpoint)
.header(ACCEPT, GITHUB_JSON_MIME)
.send()
.await?
.json::<GitTree>()
.await?;
let files = response
.tree
.iter()
Expand Down
5 changes: 5 additions & 0 deletions src/github/rest/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
use reqwest::header::HeaderValue;

pub mod get_tree;

#[allow(clippy::declare_interior_mutable_const)]
pub const GITHUB_JSON_MIME: HeaderValue = HeaderValue::from_static("application/vnd.github+json");

0 comments on commit 0b1aa38

Please sign in to comment.