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