Struct pact_models::request::Request
source · [−]pub struct Request {
pub method: String,
pub path: String,
pub query: Option<HashMap<String, Vec<String>>>,
pub headers: Option<HashMap<String, Vec<String>>>,
pub body: OptionalBody,
pub matching_rules: MatchingRules,
pub generators: Generators,
}
Expand description
Struct that defines the request.
Fields
method: String
Request method
path: String
Request path
query: Option<HashMap<String, Vec<String>>>
Request query string
headers: Option<HashMap<String, Vec<String>>>
Request headers
body: OptionalBody
Request body
matching_rules: MatchingRules
Request matching rules
generators: Generators
Request generators
Implementations
sourceimpl Request
impl Request
sourcepub fn from_json(
request_json: &Value,
spec_version: &PactSpecification
) -> Result<Request>
pub fn from_json(
request_json: &Value,
spec_version: &PactSpecification
) -> Result<Request>
Builds a Request
from a Value
struct.
sourcepub fn to_json(&self, spec_version: &PactSpecification) -> Value
pub fn to_json(&self, spec_version: &PactSpecification) -> Value
Converts this Request
to a Value
struct.
sourcepub fn default_request() -> Request
👎 Deprecated since 0.6.0: please use default()
from the standard Default trait instead
pub fn default_request() -> Request
please use default()
from the standard Default trait instead
Returns the default request: a GET request to the root.
sourcepub fn differences_from(&self, other: &Request) -> Vec<(DifferenceType, String)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn differences_from(&self, other: &Request) -> Vec<(DifferenceType, String)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return a description of all the differences from the other request
sourcepub fn as_v4_request(&self) -> HttpRequest
pub fn as_v4_request(&self) -> HttpRequest
Convert this interaction to V4 format
Trait Implementations
sourceimpl HttpPart for Request
impl HttpPart for Request
sourcefn headers(&self) -> &Option<HashMap<String, Vec<String>>>
fn headers(&self) -> &Option<HashMap<String, Vec<String>>>
Returns the headers of the HTTP part.
sourcefn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>
fn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>
Returns the headers of the HTTP part in a mutable form.
sourcefn body(&self) -> &OptionalBody
fn body(&self) -> &OptionalBody
Returns the body of the HTTP part.
sourcefn body_mut(&mut self) -> &mut OptionalBody
fn body_mut(&mut self) -> &mut OptionalBody
Returns a mutable pointer to the body of the HTTP part.
sourcefn matching_rules(&self) -> &MatchingRules
fn matching_rules(&self) -> &MatchingRules
Returns the matching rules of the HTTP part.
sourcefn matching_rules_mut(&mut self) -> &mut MatchingRules
fn matching_rules_mut(&mut self) -> &mut MatchingRules
Returns the matching rules of the HTTP part.
sourcefn generators(&self) -> &Generators
fn generators(&self) -> &Generators
Returns the generators of the HTTP part.
sourcefn generators_mut(&mut self) -> &mut Generators
fn generators_mut(&mut self) -> &mut Generators
Returns the generators of the HTTP part.
sourcefn lookup_content_type(&self) -> Option<String>
fn lookup_content_type(&self) -> Option<String>
Lookup up the content type for the part
sourcefn detect_content_type(&self) -> Option<ContentType>
fn detect_content_type(&self) -> Option<ContentType>
Tries to detect the content type of the body by matching some regular expressions against the first 32 characters. Read more
sourcefn content_type(&self) -> Option<ContentType>
fn content_type(&self) -> Option<ContentType>
Determine the content type of the HTTP part. If a Content-Type
header is present, the
value of that header will be returned. Otherwise, the body will be inspected. Read more
sourcefn has_header(&self, header_name: &str) -> bool
fn has_header(&self, header_name: &str) -> bool
Checks if the HTTP Part has the given header
sourcefn lookup_header_value(&self, header_name: &str) -> Option<String>
fn lookup_header_value(&self, header_name: &str) -> Option<String>
Checks if the HTTP Part has the given header
sourcefn has_text_body(&self) -> bool
fn has_text_body(&self) -> bool
If the body is a textual type (non-binary)
sourcefn add_header(&mut self, key: &str, val: Vec<&str>)
fn add_header(&mut self, key: &str, val: Vec<&str>)
Convenience method to add a header
sourcefn build_generators(
&self,
category: &GeneratorCategory
) -> HashMap<DocPath, Generator>
fn build_generators(
&self,
category: &GeneratorCategory
) -> HashMap<DocPath, Generator>
Builds a map of generators from the generators and matching rules
impl Eq for Request
impl StructuralEq for Request
Auto Trait Implementations
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
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<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
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>
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