pub struct RequestBuilder { /* private fields */ }Expand description
Builder for HTTP requests.
Implementations§
Source§impl RequestBuilder
impl RequestBuilder
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Adds a header to the request.
Sourcepub fn content_type(self, content_type: impl Into<String>) -> Self
pub fn content_type(self, content_type: impl Into<String>) -> Self
Sets the Content-Type header.
Sourcepub fn bearer_auth(self, token: impl Into<String>) -> Self
pub fn bearer_auth(self, token: impl Into<String>) -> Self
Sets the Authorization header with a Bearer token.
Sourcepub fn json<T: Serialize>(self, value: &T) -> Result<Self, Error>
pub fn json<T: Serialize>(self, value: &T) -> Result<Self, Error>
Sets the request body as JSON.
Sourcepub fn send(self) -> Result<HttpResponse, HttpError>
pub fn send(self) -> Result<HttpResponse, HttpError>
Sends the request and waits for the response.
Trait Implementations§
Source§impl Clone for RequestBuilder
impl Clone for RequestBuilder
Source§fn clone(&self) -> RequestBuilder
fn clone(&self) -> RequestBuilder
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 RequestBuilder
impl RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnwindSafe for RequestBuilder
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