pub struct RequestBuilder<S, B = Body> { /* private fields */ }client only.Expand description
The builder for building a request.
Implementations§
Source§impl<S> RequestBuilder<S>
impl<S> RequestBuilder<S>
Source§impl<S, B> RequestBuilder<S, B>
impl<S, B> RequestBuilder<S, B>
Sourcepub fn method_ref(&self) -> &Method
pub fn method_ref(&self) -> &Method
Get a reference to method in the request.
Sourcepub fn uri<U>(self, uri: U) -> Self
pub fn uri<U>(self, uri: U) -> Self
Set uri for building request.
The uri will be split into two parts scheme+host and path+query. The scheme and host can be empty and it will be resolved as the target address. The path and query must exist and they are used to build the request uri.
Note that only path and query will be set to the request uri. For setting the full uri, use
full_uri instead.
Sourcepub fn set_query<T>(self, query: &T) -> Selfwhere
T: Serialize,
Available on crate feature query only.
pub fn set_query<T>(self, query: &T) -> Selfwhere
T: Serialize,
query only.Set query for the uri in request from object with Serialize.
Sourcepub fn version(self, version: Version) -> Self
pub fn version(self, version: Version) -> Self
Set version of the HTTP request.
If it is not set, the request will use HTTP/2 if it is enabled and supported by default.
Sourcepub fn version_ref(&self) -> Option<Version>
pub fn version_ref(&self) -> Option<Version>
Get a reference to version in the request.
Sourcepub fn header<K, V>(self, key: K, value: V) -> Self
pub fn header<K, V>(self, key: K, value: V) -> Self
Insert a header into the request header map.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get a mutable reference to headers in the request.
Sourcepub fn host<H>(self, host: H) -> Self
pub fn host<H>(self, host: H) -> Self
Set target host for the request.
It uses http with port 80 by default.
For setting scheme and port, use Self::with_scheme and Self::with_port after
specifying host.
Sourcepub fn with_scheme(self, scheme: Scheme) -> Self
pub fn with_scheme(self, scheme: Scheme) -> Self
Set scheme for target of the request.
Sourcepub fn target_ref(&self) -> &Target
pub fn target_ref(&self) -> &Target
Get a reference to Target.
Sourcepub fn target_mut(&mut self) -> &mut Target
pub fn target_mut(&mut self) -> &mut Target
Get a mutable reference to Target.
Sourcepub fn body<B2>(self, body: B2) -> RequestBuilder<S, B2>
pub fn body<B2>(self, body: B2) -> RequestBuilder<S, B2>
Set a request body.
Sourcepub fn layer<L>(self, layer: L) -> RequestBuilder<L::Service, B>where
L: Layer<S>,
pub fn layer<L>(self, layer: L) -> RequestBuilder<L::Service, B>where
L: Layer<S>,
Add a new Layer to the front of request builder.
Note that the Layer generated Service should be a OneShotService.
Sourcepub fn with_callopt(
self,
callopt: CallOpt,
) -> RequestBuilder<WithOptService<S, CallOpt>, B>
pub fn with_callopt( self, callopt: CallOpt, ) -> RequestBuilder<WithOptService<S, CallOpt>, B>
Apply a CallOpt to the request.
Sourcepub async fn send<RespBody>(self) -> Result<Response<RespBody>>where
S: OneShotService<ClientContext, Request<B>, Response = Response<RespBody>, Error = ClientError> + Send + Sync + 'static,
B: Send + 'static,
pub async fn send<RespBody>(self) -> Result<Response<RespBody>>where
S: OneShotService<ClientContext, Request<B>, Response = Response<RespBody>, Error = ClientError> + Send + Sync + 'static,
B: Send + 'static,
Send the request and get the response.