pub struct RequestBuilder { /* private fields */ }Expand description
Builds a request, with the methods of reqwest’s RequestBuilder that generated clients use.
An error in any step (an invalid URL, header or body) is kept and returned by RequestBuilder::build.
Implementations§
Source§impl RequestBuilder
impl RequestBuilder
Sourcepub fn header<K, V>(self, name: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
pub fn header<K, V>(self, name: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Adds a header.
Sourcepub fn query<T: Serialize + ?Sized>(self, query: &T) -> Self
pub fn query<T: Serialize + ?Sized>(self, query: &T) -> Self
Appends query parameters, serialized as application/x-www-form-urlencoded: a sequence of pairs, a map or a
struct.
Sourcepub fn bearer_auth<T: Display>(self, token: T) -> Self
pub fn bearer_auth<T: Display>(self, token: T) -> Self
Sets an Authorization: Bearer header.
Sourcepub fn basic_auth<U: Display, P: Display>(
self,
username: U,
password: Option<P>,
) -> Self
pub fn basic_auth<U: Display, P: Display>( self, username: U, password: Option<P>, ) -> Self
Sets an Authorization: Basic header.
Sourcepub fn sensitive_header<K, V>(self, name: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
pub fn sensitive_header<K, V>(self, name: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Sets a header, replacing any earlier value, and marks it sensitive (see HeaderValue::set_sensitive): for
credentials such as an API key.
Sourcepub fn json<T: Serialize + ?Sized>(self, json: &T) -> Self
pub fn json<T: Serialize + ?Sized>(self, json: &T) -> Self
Sets a JSON body, and Content-Type: application/json unless a content type is set.
Sourcepub fn form<T: Serialize + ?Sized>(self, form: &T) -> Self
pub fn form<T: Serialize + ?Sized>(self, form: &T) -> Self
Sets a form body (application/x-www-form-urlencoded).
Sourcepub fn multipart(self, form: Form) -> Self
pub fn multipart(self, form: Form) -> Self
Sets a multipart/form-data body, with a Content-Length when the length of every part is known.
Sourcepub fn options(self, options: &RequestOptions) -> Self
pub fn options(self, options: &RequestOptions) -> Self
Applies the extra headers and query parameters of RequestOptions: each of its headers replaces every value
the request has under that name (call it last to override what was set before, as generated clients do), and
its query parameters are appended.