]> git.proxmox.com Git - proxmox.git/blame - proxmox-http/src/client_trait.rs
http: client_trait: make request body generic
[proxmox.git] / proxmox-http / src / client_trait.rs
CommitLineData
08a6d56e 1use std::collections::HashMap;
f429fcb5 2
3c0486be 3use anyhow::Error;
f429fcb5 4use http::{Request, Response};
3c0486be 5
08a6d56e 6pub trait HttpClient<RequestBody, ResponseBody> {
f429fcb5
FG
7 fn get(
8 &self,
9 uri: &str,
10 extra_headers: Option<&HashMap<String, String>>,
08a6d56e 11 ) -> Result<Response<ResponseBody>, Error>;
3c0486be 12
08a6d56e 13 fn post(
3c0486be
FG
14 &self,
15 uri: &str,
08a6d56e 16 body: Option<RequestBody>,
3c0486be 17 content_type: Option<&str>,
891dcfda 18 extra_headers: Option<&HashMap<String, String>>,
08a6d56e 19 ) -> Result<Response<ResponseBody>, Error>;
f429fcb5 20
08a6d56e 21 fn request(&self, request: Request<RequestBody>) -> Result<Response<ResponseBody>, Error>;
3c0486be 22}