(&self, path: &str, body: T)
| 35 | |
| 36 | impl RequestClient for PrpcClient { |
| 37 | async fn request<T, R>(&self, path: &str, body: T) -> Result<R, Error> |
| 38 | where |
| 39 | T: Message + Serialize, |
| 40 | R: Message + DeserializeOwned, |
| 41 | { |
| 42 | let body = serde_json::to_vec(&body).context("Failed to serialize body")?; |
| 43 | let path = format!("{}{path}?json", self.path_append); |
| 44 | let (status, body) = super::http_request("POST", &self.base_url, &path, &body).await?; |
| 45 | if status != 200 { |
| 46 | anyhow::bail!("Invalid status code: {status}, path={path}"); |
| 47 | } |
| 48 | let response = serde_json::from_slice(&body).context("Failed to deserialize response")?; |
| 49 | Ok(response) |
| 50 | } |
| 51 | } |
no test coverage detected