diff --git a/proxmox-http/Cargo.toml b/proxmox-http/Cargo.toml index f3a554b2..0d633f7d 100644 --- a/proxmox-http/Cargo.toml +++ b/proxmox-http/Cargo.toml @@ -31,6 +31,7 @@ proxmox-lang = { path = "../proxmox-lang", optional = true, version = "1.1" } default = [] client = [ "futures", "http-helpers", "hyper/full", "openssl", "tokio/io-util", "tokio-openssl" ] +client-trait = [ "http" ] http-helpers = [ "base64", "http", "proxmox-sys", "serde_json", "url" ] websocket = [ "base64", diff --git a/proxmox-http/src/client_trait.rs b/proxmox-http/src/client_trait.rs new file mode 100644 index 00000000..bcefa8f9 --- /dev/null +++ b/proxmox-http/src/client_trait.rs @@ -0,0 +1,13 @@ +use anyhow::Error; +use http::Response; + +pub trait HttpClient { + fn get(&self, uri: &str) -> Result, Error>; + + fn post( + &self, + uri: &str, + body: Option, + content_type: Option<&str>, + ) -> Result, Error>; +} diff --git a/proxmox-http/src/lib.rs b/proxmox-http/src/lib.rs index 9a8a6350..55c5d346 100644 --- a/proxmox-http/src/lib.rs +++ b/proxmox-http/src/lib.rs @@ -13,3 +13,8 @@ pub use proxy_config::ProxyConfig; #[cfg(feature = "client")] pub mod client; + +#[cfg(feature = "client-trait")] +mod client_trait; +#[cfg(feature = "client-trait")] +pub use client_trait::HttpClient;