[][src]Trait pact_consumer::builders::HttpPartBuilder

pub trait HttpPartBuilder {
    pub fn header<N, V>(&mut self, name: N, value: V) -> &mut Self
    where
        N: Into<String>,
        V: Into<StringPattern>
, { ... }
pub fn content_type<CT>(&mut self, content_type: CT) -> &mut Self
    where
        CT: Into<StringPattern>
, { ... }
pub fn html(&mut self) -> &mut Self { ... }
pub fn json_utf8(&mut self) -> &mut Self { ... }
pub fn body<B: Into<String>>(&mut self, body: B) -> &mut Self { ... }
pub fn body2<B: Into<String>>(
        &mut self,
        body: B,
        content_type: B
    ) -> &mut Self { ... }
pub fn json_body<B: Into<JsonPattern>>(&mut self, body: B) -> &mut Self { ... } }

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]

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]

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"),
}));
Loading content...

Implementors

impl HttpPartBuilder for RequestBuilder[src]

impl HttpPartBuilder for ResponseBuilder[src]

Loading content...