mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-15 11:18:44 +00:00
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 = []
|
default = []
|
||||||
|
|
||||||
client = [ "futures", "http-helpers", "hyper/full", "openssl", "tokio/io-util", "tokio-openssl" ]
|
client = [ "futures", "http-helpers", "hyper/full", "openssl", "tokio/io-util", "tokio-openssl" ]
|
||||||
|
client-trait = [ "http" ]
|
||||||
http-helpers = [ "base64", "http", "proxmox-sys", "serde_json", "url" ]
|
http-helpers = [ "base64", "http", "proxmox-sys", "serde_json", "url" ]
|
||||||
websocket = [
|
websocket = [
|
||||||
"base64",
|
"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")]
|
#[cfg(feature = "client")]
|
||||||
pub mod client;
|
pub mod client;
|
||||||
|
|
||||||
|
#[cfg(feature = "client-trait")]
|
||||||
|
mod client_trait;
|
||||||
|
#[cfg(feature = "client-trait")]
|
||||||
|
pub use client_trait::HttpClient;
|
||||||
|
Loading…
Reference in New Issue
Block a user