proxmox/proxmox-http/src/client_trait.rs
Fabian Grünbichler 891dcfda2f http: add extra_headers to post
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00

25 lines
570 B
Rust

use std::{collections::HashMap, io::Read};
use anyhow::Error;
use http::{Request, Response};
pub trait HttpClient<T> {
fn get(
&self,
uri: &str,
extra_headers: Option<&HashMap<String, String>>,
) -> Result<Response<T>, Error>;
fn post<R>(
&self,
uri: &str,
body: Option<R>,
content_type: Option<&str>,
extra_headers: Option<&HashMap<String, String>>,
) -> Result<Response<T>, Error>
where
R: Read;
fn request(&self, request: Request<T>) -> Result<Response<T>, Error>;
}