pub struct HttpRequestBuilder { /* private fields */ }Expand description
Builder for constructing HttpRequest instances.
Provides a fluent API for building requests with optional parameters.
Implementations§
Source§impl HttpRequestBuilder
impl HttpRequestBuilder
Sourcepub fn body(self, body: impl Into<Value>) -> Self
pub fn body(self, body: impl Into<Value>) -> Self
Sets the request body.
When setting a body, you must also set the body type via body_type.
Sourcepub const fn body_type(self, body_type: DataType) -> Self
pub const fn body_type(self, body_type: DataType) -> Self
Sets the content type of the request body.
Sourcepub fn query_param(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn query_param( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a single query parameter.
Sourcepub fn extra_headers(self, headers: HashMap<String, String>) -> Self
pub fn extra_headers(self, headers: HashMap<String, String>) -> Self
Sets all extra headers at once.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds a single extra header.
Sourcepub const fn tries(self, tries: u32) -> Self
pub const fn tries(self, tries: u32) -> Self
Sets the number of times to attempt the request.
Default is 1 (no retries). Set to a higher value to enable automatic retries for 429 and 500 responses.
Sourcepub fn build(self) -> Result<HttpRequest, InvalidHttpRequestError>
pub fn build(self) -> Result<HttpRequest, InvalidHttpRequestError>
Builds the HttpRequest, validating it in the process.
§Errors
Returns InvalidHttpRequestError if the request fails validation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HttpRequestBuilder
impl RefUnwindSafe for HttpRequestBuilder
impl Send for HttpRequestBuilder
impl Sync for HttpRequestBuilder
impl Unpin for HttpRequestBuilder
impl UnwindSafe for HttpRequestBuilder
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