mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-06 12:10:02 +00:00
feat: Add GraphQL support to GhApiClient
(#1124)
Fixed #868 - Add new fn `remote::Client::post` - Add new fn `remote::RequestBuilder::body` - Re-export `reqwest::Body` in `remote` - Add dep percent-encoding v2.2.0 to binstalk-downloader - Add dep serde-tuple-vec-map v1.0.1 to binstalk-downloader - Add GraphQL to `GhApiClient`, fallback to Restful API if token is not provided or authorization failed. - Fixed `GhReleaseArtifact::try_extract_artifact_from_str`: decode percent encoded http url path and add regression tests - Added variant `GhApiError::Context` & `GhApiContextError` - Added variant `GhApiError::GraphQLErrors` & `GhGraphQLErrors` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
e87e3534a8
commit
22b3419fce
8 changed files with 518 additions and 99 deletions
|
@ -26,7 +26,7 @@ mod certificate;
|
|||
pub use certificate::Certificate;
|
||||
|
||||
mod request_builder;
|
||||
pub use request_builder::{RequestBuilder, Response};
|
||||
pub use request_builder::{Body, RequestBuilder, Response};
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
pub use request_builder::JsonError;
|
||||
|
@ -303,6 +303,7 @@ impl Client {
|
|||
Ok(self.get(url).send(true).await?.bytes_stream())
|
||||
}
|
||||
|
||||
/// Create a new request.
|
||||
pub fn request(&self, method: Method, url: Url) -> RequestBuilder {
|
||||
RequestBuilder {
|
||||
client: self.clone(),
|
||||
|
@ -310,9 +311,15 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new GET request.
|
||||
pub fn get(&self, url: Url) -> RequestBuilder {
|
||||
self.request(Method::GET, url)
|
||||
}
|
||||
|
||||
/// Create a new POST request.
|
||||
pub fn post(&self, url: Url, body: impl Into<Body>) -> RequestBuilder {
|
||||
self.request(Method::POST, url).body(body.into())
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_header_retry_after(headers: &HeaderMap) -> Option<Duration> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue