Struct pact_consumer::builders::RequestBuilder
source · [−]pub struct RequestBuilder { /* private fields */ }
Expand description
Builder for Request
objects. Normally created via PactBuilder
.
Implementations
sourceimpl RequestBuilder
impl RequestBuilder
sourcepub fn method<M: Into<String>>(&mut self, method: M) -> &mut Self
pub fn method<M: Into<String>>(&mut self, method: M) -> &mut Self
Specify the request method. Defaults to "GET"
.
use pact_consumer::builders::RequestBuilder;
use pact_consumer::prelude::*;
let request = RequestBuilder::default().method("POST").build();
assert_eq!(request.method, "POST");
sourcepub fn get(&mut self) -> &mut Self
pub fn get(&mut self) -> &mut Self
Set the HTTP method to GET
. This is the default, so we don’t actually
care.
sourcepub fn path<P: Into<StringPattern>>(&mut self, path: P) -> &mut Self
pub fn path<P: Into<StringPattern>>(&mut self, path: P) -> &mut Self
Specify the request path. Defaults to "/"
.
sourcepub fn path_from_provider_state<E, P: Into<StringPattern>>(
&mut self,
expression: E,
path: P
) -> &mut Self where
E: Into<String>,
pub fn path_from_provider_state<E, P: Into<StringPattern>>(
&mut self,
expression: E,
path: P
) -> &mut Self where
E: Into<String>,
Specify the request path with generators. Defaults to "/"
.
sourcepub fn query_param<K, V>(&mut self, key: K, value: V) -> &mut Self where
K: Into<String>,
V: Into<StringPattern>,
pub fn query_param<K, V>(&mut self, key: K, value: V) -> &mut Self where
K: Into<String>,
V: Into<StringPattern>,
Specify a query parameter. You may pass either a single value or a list of values to represent a repeated parameter.
use pact_consumer::*;
use pact_consumer::builders::RequestBuilder;
use regex::Regex;
RequestBuilder::default()
.query_param("simple", "value")
.query_param("pattern", term!("^[0-9]+$", "123"));
To pass multiple parameters with the same name, call query_param
more
than once with the same key
.
sourcepub fn build_v4(&self) -> HttpRequest
pub fn build_v4(&self) -> HttpRequest
Build the specified Request
object in V4 format.
sourcepub async fn contents(
&mut self,
content_type: ContentType,
definition: Value
) -> &mut Self
pub async fn contents(
&mut self,
content_type: ContentType,
definition: Value
) -> &mut Self
Set the request body using the JSON data. If the body is being supplied by a plugin, this is what is sent to the plugin to setup the body.
Trait Implementations
sourceimpl Clone for RequestBuilder
impl Clone for RequestBuilder
sourcefn clone(&self) -> RequestBuilder
fn clone(&self) -> RequestBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for RequestBuilder
impl Debug for RequestBuilder
sourceimpl Default for RequestBuilder
impl Default for RequestBuilder
sourceimpl HttpPartBuilder for RequestBuilder
impl HttpPartBuilder for RequestBuilder
sourcefn header<N, V>(&mut self, name: N, value: V) -> &mut Self where
N: Into<String>,
V: Into<StringPattern>,
fn header<N, V>(&mut self, name: N, value: V) -> &mut Self where
N: Into<String>,
V: Into<StringPattern>,
Specify a header pattern. Read more
sourcefn header_from_provider_state<N, E, V>(
&mut self,
name: N,
expression: E,
value: V
) -> &mut Self where
N: Into<String>,
E: Into<String>,
V: Into<StringPattern>,
fn header_from_provider_state<N, E, V>(
&mut self,
name: N,
expression: E,
value: V
) -> &mut Self where
N: Into<String>,
E: Into<String>,
V: Into<StringPattern>,
Specify a header pattern and a generator from provider state. Read more
sourcefn content_type<CT>(&mut self, content_type: CT) -> &mut Self where
CT: Into<StringPattern>,
fn content_type<CT>(&mut self, content_type: CT) -> &mut Self where
CT: Into<StringPattern>,
Set the Content-Type
header.
sourcefn json_utf8(&mut self) -> &mut Self
fn json_utf8(&mut self) -> &mut Self
Set the Content-Type
header to application/json; charset=utf-8
,
with enough flexibility to cover common variations. Read more
sourcefn body<B: Into<String>>(&mut self, body: B) -> &mut Self
fn body<B: Into<String>>(&mut self, body: B) -> &mut Self
Specify a body literal. This does not allow using patterns. Read more
Auto Trait Implementations
impl RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnwindSafe for RequestBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more