Struct pact_consumer::builders::ResponseBuilder
source · [−]pub struct ResponseBuilder { /* private fields */ }
Expand description
Builder for Response
objects. Normally created via PactBuilder
.
Implementations
sourceimpl ResponseBuilder
impl ResponseBuilder
sourcepub fn status(&mut self, status: u16) -> &mut Self
pub fn status(&mut self, status: u16) -> &mut Self
Set the status code for the response. Defaults to 200
.
use pact_consumer::builders::ResponseBuilder;
use pact_consumer::prelude::*;
let response = ResponseBuilder::default().status(404).build();
assert_eq!(response.status, 404);
sourcepub fn no_content(&mut self) -> &mut Self
pub fn no_content(&mut self) -> &mut Self
Set the status code to 204 No Content
.
Set the status code to 401 Unauthorized
.
sourcepub fn build_v4(&self) -> HttpResponse
pub fn build_v4(&self) -> HttpResponse
Build the specified Response
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 body using the definition. 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 ResponseBuilder
impl Clone for ResponseBuilder
sourcefn clone(&self) -> ResponseBuilder
fn clone(&self) -> ResponseBuilder
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 ResponseBuilder
impl Debug for ResponseBuilder
sourceimpl Default for ResponseBuilder
impl Default for ResponseBuilder
sourceimpl HttpPartBuilder for ResponseBuilder
impl HttpPartBuilder for ResponseBuilder
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 ResponseBuilder
impl Send for ResponseBuilder
impl Sync for ResponseBuilder
impl Unpin for ResponseBuilder
impl UnwindSafe for ResponseBuilder
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