pub struct HttpClient { /* private fields */ }
Expand description
HTTP client with automatic authentication and error handling
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(config: HttpConfig) -> Result<Self>
pub fn new(config: HttpConfig) -> Result<Self>
Create a new HTTP client with the given configuration
Sourcepub fn config(&self) -> &HttpConfig
pub fn config(&self) -> &HttpConfig
Get a reference to the client configuration
Sourcepub async fn get<T: DeserializeOwned>(
&self,
auth: &dyn Auth,
path: &str,
query_params: Option<&HashMap<String, String>>,
) -> Result<T>
pub async fn get<T: DeserializeOwned>( &self, auth: &dyn Auth, path: &str, query_params: Option<&HashMap<String, String>>, ) -> Result<T>
Send a GET request
Sourcepub async fn post<T: DeserializeOwned, B: Serialize>(
&self,
auth: &dyn Auth,
path: &str,
query_params: Option<&HashMap<String, String>>,
body: Option<&B>,
) -> Result<T>
pub async fn post<T: DeserializeOwned, B: Serialize>( &self, auth: &dyn Auth, path: &str, query_params: Option<&HashMap<String, String>>, body: Option<&B>, ) -> Result<T>
Send a POST request with JSON body
Sourcepub async fn post_form<T: DeserializeOwned>(
&self,
auth: &dyn Auth,
path: &str,
query_params: Option<&HashMap<String, String>>,
form_data: &HashMap<String, String>,
) -> Result<T>
pub async fn post_form<T: DeserializeOwned>( &self, auth: &dyn Auth, path: &str, query_params: Option<&HashMap<String, String>>, form_data: &HashMap<String, String>, ) -> Result<T>
Send a POST request with form-encoded data
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for HttpClient
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl !UnwindSafe for HttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more