pub enum Matcher {
Exact(String),
Binary(BinaryBody),
Regex(String),
Json(Value),
JsonString(String),
PartialJson(Value),
PartialJsonString(String),
UrlEncoded(String, String),
AnyOf(Vec<Matcher>),
AllOf(Vec<Matcher>),
Any,
Missing,
}
Expand description
Allows matching the request path, headers or body in multiple ways: by the exact value, by any value (as long as it is present), by regular expression or by checking that a particular header is missing.
These matchers can be used within the Server::mock
, Mock::match_header
or Mock::match_body
calls.
Variants§
Exact(String)
Matches the exact path or header value. There’s also an implementation of From<&str>
to keep things simple and backwards compatible.
Binary(BinaryBody)
Matches the body content as a binary file
Regex(String)
Matches a path or header value by a regular expression.
Json(Value)
Matches a specified JSON body from a serde_json::Value
JsonString(String)
Matches a specified JSON body from a String
PartialJson(Value)
Matches a partial JSON body from a serde_json::Value
PartialJsonString(String)
Matches a specified partial JSON body from a String
UrlEncoded(String, String)
Matches a URL-encoded key/value pair, where both key and value should be specified in plain (unencoded) format
AnyOf(Vec<Matcher>)
At least one matcher must match
AllOf(Vec<Matcher>)
All matchers must match
Any
Matches any path or any header value.
Missing
Checks that a header is not present in the request.