[−][src]Trait pact_consumer::builders::HttpPartBuilder
Various methods shared between RequestBuilder
and ResponseBuilder
.
Provided methods
pub fn header<N, V>(&mut self, name: N, value: V) -> &mut Self where
N: Into<String>,
V: Into<StringPattern>,
[src]
N: Into<String>,
V: Into<StringPattern>,
Specify a header pattern.
use pact_consumer::prelude::*; use pact_consumer::*; use pact_consumer::builders::RequestBuilder; use regex::Regex; RequestBuilder::default() .header("X-Simple", "value") .header("X-Digits", term!("^[0-9]+$", "123"));
pub fn content_type<CT>(&mut self, content_type: CT) -> &mut Self where
CT: Into<StringPattern>,
[src]
CT: Into<StringPattern>,
Set the Content-Type
header.
pub fn html(&mut self) -> &mut Self
[src]
Set the Content-Type
header to text/html
.
pub fn json_utf8(&mut self) -> &mut Self
[src]
Set the Content-Type
header to application/json; charset=utf-8
,
with enough flexibility to cover common variations.
pub fn body<B: Into<String>>(&mut self, body: B) -> &mut Self
[src]
Specify a body literal. This does not allow using patterns.
use pact_consumer::prelude::*; use pact_consumer::builders::RequestBuilder; RequestBuilder::default().body("Hello");
TODO: We may want to change this to B: Into<Vec<u8>>
depending on what
happens with https://github.com/pact-foundation/pact-reference/issues/19
pub fn body2<B: Into<String>>(&mut self, body: B, content_type: B) -> &mut Self
[src]
Specify a body literal with content type. This does not allow using patterns.
use pact_consumer::prelude::*; use pact_consumer::builders::RequestBuilder; RequestBuilder::default().body2("Hello", "plain/text");
TODO: We may want to change this to B: Into<Vec<u8>>
depending on what
happens with https://github.com/pact-foundation/pact-reference/issues/19
pub fn json_body<B: Into<JsonPattern>>(&mut self, body: B) -> &mut Self
[src]
Specify the body as JsonPattern
, possibly including special matching
rules.
use pact_consumer::prelude::*; use pact_consumer::*; use pact_consumer::builders::RequestBuilder; RequestBuilder::default().json_body(json_pattern!({ "message": like!("Hello"), }));
Implementors
impl HttpPartBuilder for RequestBuilder
[src]
pub fn headers_and_matching_rules_mut(
&mut self
) -> (&mut HashMap<String, Vec<String>>, &mut MatchingRules)
[src]
&mut self
) -> (&mut HashMap<String, Vec<String>>, &mut MatchingRules)
pub fn body_and_matching_rules_mut(
&mut self
) -> (&mut OptionalBody, &mut MatchingRules)
[src]
&mut self
) -> (&mut OptionalBody, &mut MatchingRules)
impl HttpPartBuilder for ResponseBuilder
[src]
pub fn headers_and_matching_rules_mut(
&mut self
) -> (&mut HashMap<String, Vec<String>>, &mut MatchingRules)
[src]
&mut self
) -> (&mut HashMap<String, Vec<String>>, &mut MatchingRules)
pub fn body_and_matching_rules_mut(
&mut self
) -> (&mut OptionalBody, &mut MatchingRules)
[src]
&mut self
) -> (&mut OptionalBody, &mut MatchingRules)