28 lines
682 B
Rust
28 lines
682 B
Rust
use ovlach_data::cv::data::CV;
|
|
use reqwest::Client;
|
|
use tracing::{debug, instrument};
|
|
|
|
|
|
#[derive(Debug)]
|
|
pub enum FetchError {
|
|
ReqwestError(reqwest::Error)
|
|
}
|
|
|
|
impl From<reqwest::Error> for FetchError {
|
|
fn from(e: reqwest::Error) -> Self {
|
|
FetchError::ReqwestError(e)
|
|
}
|
|
}
|
|
|
|
#[instrument]
|
|
pub async fn fetch_cv_data_from_backend(backend_host: &String, person_name: &String, client: &Client) -> Result<CV, FetchError> {
|
|
let url = format!("{}/{}/{}", backend_host, "api/v1/cv", person_name);
|
|
debug!("Fetching CV data from backend: {}", url);
|
|
let resp = client
|
|
.get(url).send()
|
|
.await?
|
|
.json::<CV>()
|
|
.await?;
|
|
Ok(resp)
|
|
}
|