proxmox/proxmox-http/src/client_trait.rs
Fabian Grünbichler 08a6d56eae http: client_trait: make request body generic
like the response body, instead of hard-coding Read.
2022-09-07 09:25:47 +02:00

23 lines
606 B
Rust

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