diff options
| author | soryu <soryu@soryu.co> | 2026-01-20 00:23:49 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-20 00:23:49 +0000 |
| commit | 5d8e3f80254f20eb6672701fad5f116a3b05dbc3 (patch) | |
| tree | 02cc73bd49a416112c9dd7f21c480c156068827c /makima/src/daemon/api/client.rs | |
| parent | 9aac84bb20c4ca73f113fe74b9a293e4d20cdc93 (diff) | |
| download | soryu-5d8e3f80254f20eb6672701fad5f116a3b05dbc3.tar.gz soryu-5d8e3f80254f20eb6672701fad5f116a3b05dbc3.zip | |
Fix: auth for CLI and CLI SIGTERM
Diffstat (limited to 'makima/src/daemon/api/client.rs')
| -rw-r--r-- | makima/src/daemon/api/client.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/makima/src/daemon/api/client.rs b/makima/src/daemon/api/client.rs index 2318d5a..ca1b2a8 100644 --- a/makima/src/daemon/api/client.rs +++ b/makima/src/daemon/api/client.rs @@ -105,6 +105,28 @@ impl ApiClient { self.handle_response(response).await } + /// Make a DELETE request. + pub async fn delete(&self, path: &str) -> Result<(), ApiError> { + let url = format!("{}{}", self.base_url, path); + let response = self.client + .delete(&url) + .header("X-Makima-Tool-Key", &self.api_key) + .header("X-Makima-API-Key", &self.api_key) + .send() + .await?; + + let status = response.status(); + if !status.is_success() { + let body = response.text().await.unwrap_or_default(); + return Err(ApiError::Api { + status: status.as_u16(), + message: body, + }); + } + + Ok(()) + } + /// Handle API response. async fn handle_response<T: DeserializeOwned>( &self, |
