canic_core/api/ic/
http.rs1use crate::{PublicError, dto, workflow::http::HttpWorkflow};
2use serde::de::DeserializeOwned;
3
4pub struct HttpApi;
12
13impl HttpApi {
14 pub async fn get<T: DeserializeOwned>(
17 url: &str,
18 headers: &[(&str, &str)],
19 ) -> Result<T, PublicError> {
20 HttpWorkflow::get(url, headers)
21 .await
22 .map_err(PublicError::from)
23 }
24
25 pub async fn get_with_label<T: DeserializeOwned>(
28 url: &str,
29 headers: &[(&str, &str)],
30 label: &str,
31 ) -> Result<T, PublicError> {
32 HttpWorkflow::get_with_label(url, headers, label)
33 .await
34 .map_err(PublicError::from)
35 }
36
37 pub async fn get_raw(
39 args: dto::http::HttpRequestArgs,
40 ) -> Result<dto::http::HttpRequestResult, PublicError> {
41 HttpWorkflow::get_raw(args).await.map_err(PublicError::from)
42 }
43}