http: add HttpClient trait
gated behind feature "client-trait" Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
94456ee4b1
commit
3c0486be50
@ -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",
|
||||
|
13
proxmox-http/src/client_trait.rs
Normal file
13
proxmox-http/src/client_trait.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use anyhow::Error;
|
||||
use http::Response;
|
||||
|
||||
pub trait HttpClient<T> {
|
||||
fn get(&self, uri: &str) -> Result<Response<T>, Error>;
|
||||
|
||||
fn post(
|
||||
&self,
|
||||
uri: &str,
|
||||
body: Option<String>,
|
||||
content_type: Option<&str>,
|
||||
) -> Result<Response<T>, Error>;
|
||||
}
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user