pub struct RequestBuilder { /* private fields */ }Expand description
A builder to construct the properties of a Request.
To construct a RequestBuilder, refer to the Client documentation.
Implementations§
Source§impl RequestBuilder
impl RequestBuilder
Sourcepub fn header<K, V>(self, key: K, value: V) -> Self
pub fn header<K, V>(self, key: K, value: V) -> Self
Add a Header to this Request.
This method allows you to add a single header to the request.
Sourcepub fn headers(self, headers: HeaderMap) -> Self
pub fn headers(self, headers: HeaderMap) -> Self
Add a set of Headers to the existing ones on this Request.
This method merges the provided headers with any already set on the request.
Sourcepub fn body<T: Into<Body>>(self, body: T) -> Self
pub fn body<T: Into<Body>>(self, body: T) -> Self
Set the request body.
This method sets the body of the request to the provided value.
Sourcepub fn json<T: Serialize + ?Sized>(self, json: &T) -> Self
pub fn json<T: Serialize + ?Sized>(self, json: &T) -> Self
Send a JSON body.
This method serializes the provided data structure as JSON and sets it as the request body.
§Errors
Serialization can fail if T’s implementation of Serialize decides to
fail, or if T contains a map with non-string keys.
Sourcepub fn prove_failed_request(self) -> Self
pub fn prove_failed_request(self) -> Self
Add an instruction to prove failed request.
This method adds a header to instruct Verity Prover to prove the response, even if its status code is not success.
Sourcepub fn redact(self, redact: String) -> Self
pub fn redact(self, redact: String) -> Self
Add a Redact instruction.
This method adds a header to instruct Verity Prover on how to hide sensitive data.
Sourcepub fn build(self) -> Result<Request>
pub fn build(self) -> Result<Request>
Build a Request.
This method constructs the request, which can then be
inspected, modified and executed with VerityClient::execute().
Sourcepub fn build_split(self) -> (VerityClient, Result<Request>)
pub fn build_split(self) -> (VerityClient, Result<Request>)
Build a Request, which can be inspected, modified and executed with
VerityClient::execute().
This is similar to RequestBuilder::build(), but also returns the
embedded VerityClient.
Sourcepub async fn send(self) -> Result<VerityResponse>
pub async fn send(self) -> Result<VerityResponse>
Constructs the Request and sends it to the target URL, returning a future Response.
§Errors
This method fails if there was an error while sending request, redirect loop was detected or redirect limit was exhausted.
§Example
let config = VerityClientConfig {
prover_url: String::from("http://127.0.0.1:8080"),
};
let response = VerityClient::new(config)
.get("https://hyper.rs")
.send()
.await?;