polyte_data/api/
health.rs1use reqwest::Client;
2use serde::{Deserialize, Serialize};
3use url::Url;
4
5use crate::error::DataApiError;
6
7#[derive(Clone)]
9pub struct Health {
10 pub(crate) client: Client,
11 pub(crate) base_url: Url,
12}
13
14impl Health {
15 pub async fn check(&self) -> Result<HealthResponse, DataApiError> {
17 let response = self.client.get(self.base_url.clone()).send().await?;
18 let status = response.status();
19
20 if !status.is_success() {
21 return Err(DataApiError::from_response(response).await);
22 }
23
24 let health: HealthResponse = response.json().await?;
25 Ok(health)
26 }
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct HealthResponse {
32 pub data: String,
34}