canic_core/api/ic/
http.rs1use crate::{
2 dto::{
3 error::Error,
4 http::{HttpRequestArgs, HttpRequestResult},
5 },
6 workflow::http::HttpWorkflow,
7};
8use serde::de::DeserializeOwned;
9
10pub struct HttpApi;
18
19impl HttpApi {
20 pub async fn get<T: DeserializeOwned>(url: &str, headers: &[(&str, &str)]) -> Result<T, Error> {
23 HttpWorkflow::get(url, headers).await.map_err(Error::from)
24 }
25
26 pub async fn get_with_label<T: DeserializeOwned>(
29 url: &str,
30 headers: &[(&str, &str)],
31 label: &str,
32 ) -> Result<T, Error> {
33 HttpWorkflow::get_with_label(url, headers, label)
34 .await
35 .map_err(Error::from)
36 }
37
38 pub async fn get_raw(args: HttpRequestArgs) -> Result<HttpRequestResult, Error> {
40 HttpWorkflow::get_raw(args).await.map_err(Error::from)
41 }
42}