Watch
0
0
Fork
You've already forked hyperhive
0

hive-forge: ci-rerun takes repeatable --input key=value for workflow dispatch

The dispatch goes out as a raw API POST so a forge rejection of an input
reaches the caller with its response body.
This commit is contained in:
atlas 2026-11-19 10:26:32 +01:00 • committed by mara
commit 439cb28c8c

View file

@ -212,6 +212,31 @@ impl Client {
})
}
/// POST a JSON body to `/api/v1<path>` and discard a 2xx response body.
/// Raw instead of through `forgejo-api` for endpoints where that crate
/// maps every non-2xx status except `404` to a bare "unexpected status
/// code", dropping the forge's explanation: here a non-2xx surfaces as a
/// [`WebStatusError`] carrying the response body. `path` starts with `/`.
///
/// # Errors
/// Returns an error on transport failure or a non-2xx response (body
/// included).
pub fn post_api_json<B: Serialize>(&self, path: &str, body: &B) -> Result<()> {
let url = format!("{}/api/v1{path}", self.base);
let resp = self
.web
.post(&url)
.json(body)
.timeout(JSON_TIMEOUT)
.send()
.map_err(|e| {
let ctx = http_context("POST", &e, JSON_TIMEOUT);
anyhow::Error::new(e).context(ctx)
})?;
check_status(resp, &format!("POST {url}"))?;
Ok(())
}
/// GET a raw (non-API) URL and return the response body as bytes.
/// Stays on the raw `reqwest` client because these are *web-router*
/// routes (`/attachments/<uuid>`, Actions artifact / persisted-log