pub struct HttpClient { /* private fields */ }Expand description
HTTP client wrapper
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn builder() -> HttpClientBuilder
pub fn builder() -> HttpClientBuilder
Create a new HTTP client builder
Sourcepub fn from_reqwest(client: Client) -> Self
pub fn from_reqwest(client: Client) -> Self
Create an HttpClient from a reqwest::Client
Sourcepub async fn fetch<R>(&self, url: &str) -> Response<R>where
R: DeserializeOwned,
pub async fn fetch<R>(&self, url: &str) -> Response<R>where
R: DeserializeOwned,
GET request, returns JSON deserialized to R
Sourcepub async fn post_json<B, R>(&self, url: &str, body: &B) -> Response<R>
pub async fn post_json<B, R>(&self, url: &str, body: &B) -> Response<R>
POST with JSON body, returns JSON deserialized to R
Sourcepub async fn post_form<F, R>(&self, url: &str, form: &F) -> Response<R>
pub async fn post_form<F, R>(&self, url: &str, form: &F) -> Response<R>
POST with form data, returns JSON deserialized to R
Sourcepub async fn patch_json<B, R>(&self, url: &str, body: &B) -> Response<R>
pub async fn patch_json<B, R>(&self, url: &str, body: &B) -> Response<R>
PATCH with JSON body, returns JSON deserialized to R
Sourcepub async fn get_raw(&self, url: &str) -> Response<RawResponse>
pub async fn get_raw(&self, url: &str) -> Response<RawResponse>
GET request returning raw response body
Sourcepub fn post(&self, url: &str) -> RequestBuilder
pub fn post(&self, url: &str) -> RequestBuilder
POST request builder for complex cases (custom headers, form data, etc.)
Sourcepub fn get(&self, url: &str) -> RequestBuilder
pub fn get(&self, url: &str) -> RequestBuilder
GET request builder for complex cases (custom headers, etc.)
Sourcepub fn patch(&self, url: &str) -> RequestBuilder
pub fn patch(&self, url: &str) -> RequestBuilder
PATCH request builder for complex cases (custom headers, JSON body, etc.)
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 moreSource§impl Debug for HttpClient
impl Debug for HttpClient
Auto Trait Implementations§
impl Freeze for HttpClient
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnsafeUnpin 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