pub struct RequestBuilder<'a, T = ()> { /* private fields */ }Expand description
Generic request builder. Used to construct custom requests towards CDF.
Implementations§
Source§impl<'a> RequestBuilder<'a, ()>
impl<'a> RequestBuilder<'a, ()>
Source§impl<'a, T> RequestBuilder<'a, T>
impl<'a, T> RequestBuilder<'a, T>
Sourcepub fn header<K, V>(self, key: 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, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Sourcepub fn json<B: Serialize + ?Sized>(self, body: &B) -> Result<Self>
pub fn json<B: Serialize + ?Sized>(self, body: &B) -> Result<Self>
Add a JSON body to the request. This sets CONTENT_TYPE.
Sourcepub fn body(self, body: impl Into<Body>) -> Self
pub fn body(self, body: impl Into<Body>) -> Self
Add a body to the request. You will typically want to set CONTENT_TYPE yourself.
Sourcepub fn protobuf<B: Message>(self, body: &B) -> Self
pub fn protobuf<B: Message>(self, body: &B) -> Self
Add a protobuf message as body to the request. This sets CONTENT_TYPE
Sourcepub fn omit_auth_headers(self) -> Self
pub fn omit_auth_headers(self) -> Self
Omit authentication headers in the request.
This should be set before calling untrusted URLs.
Sourcepub fn with_inner<R: FnOnce(RequestBuilder) -> RequestBuilder>(
self,
m: R,
) -> Self
pub fn with_inner<R: FnOnce(RequestBuilder) -> RequestBuilder>( self, m: R, ) -> Self
Modify the inner request builder.
Source§impl<'a> RequestBuilder<'a, ()>
impl<'a> RequestBuilder<'a, ()>
Sourcepub fn accept_json<T: DeserializeOwned>(
self,
) -> RequestBuilder<'a, JsonResponseHandler<T>>
pub fn accept_json<T: DeserializeOwned>( self, ) -> RequestBuilder<'a, JsonResponseHandler<T>>
Expect the response for a successful request to be T encoded as JSON.
Sourcepub fn accept_protobuf<T: Message + Default + Send + Sync>(
self,
) -> RequestBuilder<'a, ProtoResponseHandler<T>>
pub fn accept_protobuf<T: Message + Default + Send + Sync>( self, ) -> RequestBuilder<'a, ProtoResponseHandler<T>>
Expect the response for a successful request to be T encoded as protobuf.
Sourcepub fn accept_nothing(self) -> RequestBuilder<'a, NoResponseHandler>
pub fn accept_nothing(self) -> RequestBuilder<'a, NoResponseHandler>
Ignore the response for a successful request.
Sourcepub fn accept_raw(self) -> RequestBuilder<'a, RawResponseHandler>
pub fn accept_raw(self) -> RequestBuilder<'a, RawResponseHandler>
Simply return the raw payload on a successful request.
Sourcepub fn accept<T: ResponseHandler>(self, handler: T) -> RequestBuilder<'a, T>
pub fn accept<T: ResponseHandler>(self, handler: T) -> RequestBuilder<'a, T>
Set the response handler T.
Source§impl<T: ResponseHandler> RequestBuilder<'_, T>
impl<T: ResponseHandler> RequestBuilder<'_, T>
Sourcepub async fn send(self) -> Result<T::Output>
pub async fn send(self) -> Result<T::Output>
Send the request. This sets a few core headers, and converts any errors into crate::Error