pub struct RequestFactory { /* private fields */ }Implementations§
Source§impl RequestFactory
impl RequestFactory
Sourcepub fn new(base_url: impl AsRef<str>) -> Result<Self, HttpError>
pub fn new(base_url: impl AsRef<str>) -> Result<Self, HttpError>
Creates a request factory rooted at base_url.
The factory starts without authentication and sends JSON-oriented Accept
and XBP User-Agent headers on every request.
Sourcepub fn with_auth(self, auth: AuthStrategy) -> Self
pub fn with_auth(self, auth: AuthStrategy) -> Self
Returns a copy of this factory configured with the selected authentication strategy.
Sourcepub fn with_default_header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn with_default_header(self, name: HeaderName, value: HeaderValue) -> Self
Returns a copy of this factory with an additional default request header.
Sourcepub async fn get_json<T, Q>(
&self,
path: &str,
query: Option<&Q>,
) -> Result<T, HttpError>
pub async fn get_json<T, Q>( &self, path: &str, query: Option<&Q>, ) -> Result<T, HttpError>
Sends a GET request and deserializes its JSON response into T.
Sourcepub async fn delete_json<T, Q>(
&self,
path: &str,
query: Option<&Q>,
) -> Result<T, HttpError>
pub async fn delete_json<T, Q>( &self, path: &str, query: Option<&Q>, ) -> Result<T, HttpError>
Sends a DELETE request and deserializes its JSON response into T.
Sourcepub async fn delete_json_with_body<T, Q, B>(
&self,
path: &str,
query: Option<&Q>,
body: &B,
) -> Result<T, HttpError>
pub async fn delete_json_with_body<T, Q, B>( &self, path: &str, query: Option<&Q>, body: &B, ) -> Result<T, HttpError>
Sends a DELETE request with an optional query and JSON body.
Sourcepub async fn post_json<T, B>(
&self,
path: &str,
body: &B,
) -> Result<T, HttpError>
pub async fn post_json<T, B>( &self, path: &str, body: &B, ) -> Result<T, HttpError>
Sends a POST request with a JSON body and deserializes its response.
Sourcepub async fn put_json<T, B>(&self, path: &str, body: &B) -> Result<T, HttpError>
pub async fn put_json<T, B>(&self, path: &str, body: &B) -> Result<T, HttpError>
Sends a PUT request with a JSON body and deserializes its response.
Sourcepub async fn put_multipart_json<T>(
&self,
path: &str,
form: Form,
) -> Result<T, HttpError>where
T: DeserializeOwned,
pub async fn put_multipart_json<T>(
&self,
path: &str,
form: Form,
) -> Result<T, HttpError>where
T: DeserializeOwned,
Sends a multipart PUT request and deserializes its JSON response.
Sourcepub async fn post_multipart_json<T>(
&self,
path: &str,
form: Form,
) -> Result<T, HttpError>where
T: DeserializeOwned,
pub async fn post_multipart_json<T>(
&self,
path: &str,
form: Form,
) -> Result<T, HttpError>where
T: DeserializeOwned,
Sends a multipart POST request and deserializes its JSON response.
Sourcepub async fn patch_json<T, B>(
&self,
path: &str,
body: &B,
) -> Result<T, HttpError>
pub async fn patch_json<T, B>( &self, path: &str, body: &B, ) -> Result<T, HttpError>
Sends a PATCH request with a JSON body and deserializes its response.
Sourcepub async fn post_bytes(
&self,
path: &str,
bytes: Vec<u8>,
content_type: &'static str,
) -> Result<ResponseBytes, HttpError>
pub async fn post_bytes( &self, path: &str, bytes: Vec<u8>, content_type: &'static str, ) -> Result<ResponseBytes, HttpError>
Sends raw bytes in a POST request and returns the response body unchanged.
Trait Implementations§
Source§impl Clone for RequestFactory
impl Clone for RequestFactory
Source§fn clone(&self) -> RequestFactory
fn clone(&self) -> RequestFactory
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more