DELETE request, returns `()` on success.
(&self, path: &str)
| 218 | |
| 219 | /// DELETE request, returns `()` on success. |
| 220 | pub async fn delete(&self, path: &str) -> Result<(), RemoteError> { |
| 221 | let url = format!("{}{}", self.base_url, path); |
| 222 | log::debug!("DELETE {}", url); |
| 223 | |
| 224 | let resp = self |
| 225 | .http |
| 226 | .delete(&url) |
| 227 | .send() |
| 228 | .await |
| 229 | .map_err(|e| RemoteError::other(format!("request failed: {}", e)))?; |
| 230 | |
| 231 | crate::check_min_version_header(resp.headers()); |
| 232 | let status = resp.status(); |
| 233 | if status.is_success() { |
| 234 | Ok(()) |
| 235 | } else { |
| 236 | let body = resp.text().await.unwrap_or_default(); |
| 237 | Err(self.parse_error_body(status.as_u16(), &body)) |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | /// Handle a response: check status, parse `ApiResponse<T>`, unwrap data. |
| 242 | async fn handle_response<T: DeserializeOwned>( |
no test coverage detected