pub struct ApiRequest { /* private fields */ }Expand description
One api.github.com request, before authentication headers are applied.
Debug is written by hand and never renders the body: c4 posts
generate-jitconfig requests through this type, and a JIT configuration is
a sensitive short-lived value (07-security.md, credential inventory).
Implementations§
Source§impl ApiRequest
impl ApiRequest
pub fn get(path: impl Into<String>) -> Self
pub fn delete(path: impl Into<String>) -> Self
pub fn new(method: Method, path: impl Into<String>) -> Self
Sourcepub fn post_json<T: Serialize>(
path: impl Into<String>,
body: &T,
) -> Result<Self, GithubError>
pub fn post_json<T: Serialize>( path: impl Into<String>, body: &T, ) -> Result<Self, GithubError>
§Errors
body failing to serialize.
pub fn query(self, key: impl Into<String>, value: impl Display) -> Self
Sourcepub fn conditional(self, validators: Validators) -> Self
pub fn conditional(self, validators: Validators) -> Self
Make this a conditional request: GitHub answers 304 Not Modified,
with no body, while the resource still matches validators.
Only meaningful on a GET. GitHub: “Conditional requests for unsafe
methods, such as POST, PUT, PATCH, and DELETE are not supported
unless otherwise noted in the documentation.”
Sourcepub const fn is_conditional(&self) -> bool
pub const fn is_conditional(&self) -> bool
Whether this request carries validators, and so may be answered 304.
Sourcepub fn cache_key(&self) -> String
pub fn cache_key(&self) -> String
The resource this request reads: method, path, and query in the order
it was added. An ETag is scoped to exactly this — GitHub: “Use the
same parameters every time you poll the same data. A different page
size, page number, or filter produces a different response with a
different etag.”