proxmox/proxmox-http/src/client_trait.rs
Fabian Grünbichler f429fcb592 http: extend HttpClient trait
to allow get requests with extra headers (such as `Authorization`) and a
generic `request` fn to increase flexibility even more.

this is a breaking change.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00

22 lines
475 B
Rust

use std::collections::HashMap;
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(
&self,
uri: &str,
body: Option<&str>,
content_type: Option<&str>,
) -> Result<Response<T>, Error>;
fn request(&self, request: Request<T>) -> Result<Response<T>, Error>;
}