INNER CODE UNIT · Rust

client

orhun/git-cliff · git-cliff-core/src/remote/mod.rs:168

    fn client(&self) -> ClientWithMiddleware;

    /// Performs a HTTP GET request, deserializes the JSON response, and returns the result.
    /// This is the core HTTP request and JSON parsing logic shared by all API methods.
    /// Callers are responsible for any additional processing of the deserialized data.
    async fn get_json<T: DeserializeOwned>(&self, url: &str) -> Result<T> {
        tracing::debug!("Sending request to: {url}");
        let response = self.client().get(url).send().await?.error_for_status()?;
        let response_text = if response.status().is_success() {
            let text = response.text().await?;
            tracing::trace!("Response: {text:?}");
            text
        } else {
            let text = response.text().await?;
            tracing::error!("Request error: {text}");
            text
        };
        Ok(serde_json::from_str::<T>(&response_text)?)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…