.. _request_matchers: Request matchers ================ A Request Matcher is used to define the desired value for a specific request field when matching against incoming requests. Given a **matcher value** and **string to match**, each matcher will transform and compare the values in a different way. Exact matcher ------------- Evaluates the equality of the matcher value and the string to match. There are no transformations. This is the default Request Matcher type which is set by Hoverfly when requests and responses are captured. Example """"""" .. code:: json "matcher": "exact" "value": "?" .. raw:: html
| String to match | Matcher value | Match |
|---|---|---|
| docs.hoverfly.io | docs.hoverfly.io | |
| specto.io | docs.hoverfly.io | |
| String to match | Matcher value | Match |
|---|---|---|
| cloud.hoverfly.io | docs.hoverfly.io | |
| cloud.hoverfly.io | ||
| cloud.hoverfly.io | ||
| cloud.hoverfly.io | cloud.hoverfly.io | |
| String to match | Matcher value | Match |
|---|---|---|
| docs.hoverfly.io | *.hoverfly.io | |
| docs.specto.io | *.hoverfly.io | |
| docs.hoverfly.io | h*verfly.* | |
| hooverfly.com | h*verfly.* | |
| String to match | Matcher value | Match |
|---|---|---|
| docs.hoverfly.io | (\\Ad) | |
| hoverfly.io | (\\Ad) | |
| docs.hoverfly.io | (.*).(.*).(io|com|biz) | |
| buy.stuff.biz | (.*).(.*).(io|com|biz) | |
| String to match | Matcher value | Match |
|---|---|---|
| <?xml version="1.0" encoding="UTF-8"?> <document type="book"> Hoverfly Documentation </document> | <?xml version="1.0" encoding="UTF-8"?> <document type="book"> Hoverfly Documentation </document> | |
| <?xml version="1.0" encoding="UTF-8"?> <documents type="book"> <document type="book"> Hoverfly Documentation </document> </document> | <?xml version="1.0" encoding="UTF-8"?> <document type="book"> Hoverfly Documentation </document> | |
| String to match | Matcher value | Match |
|---|---|---|
| <?xml version="1.0" encoding="UTF-8"?> <documents> <document> Hoverfly Documentation </document> </documents> | /documents | |
| <?xml version="1.0" encoding="UTF-8"?> <document> Hoverfly Documentation </document> | /documents | |
| <?xml version="1.0" encoding="UTF-8"?> <documents> <document type="book"> Hoverfly Documentation </document> </documents> | /documents/document[2] | |
| <?xml version="1.0" encoding="UTF-8"?> <documents type="book"> <document> Someone Else's Documentation </document> <document> Hoverfly Documentation </document> </documents> | /documents/document[2] | |
| String to match | Matcher value | Match |
|---|---|---|
| { "objects": [ { "name": "Object 1", "set": true },{ "name": "Object 2", "set": false, "age": 400 }] } | { "objects": [ { "name": "Object 1", "set": true },{ "name": "Object 2", "set": false, "age": 400 }] } | |
| { "objects": [ { "name": "Object 1", "set": true }] } | { "objects": [ { "name": "Object 1", "set": true },{ "name": "Object 2", "set": false, "age": 400 }] } | |
| String to match | Matcher value | Match |
|---|---|---|
| { "objects": [ { "name": "Object 1", },{ "name": "Object 2", "set": false, "age": 400 }] } | { "objects": [ { "name": "Object 1" },{ "name": "Object 2" }] } | |
| { "objects": [ { "name": "Object 1", },{ "name": "Object 2", "set": false, "age": 400 }] } | { "name": "Object 2", "set": false, "age": 400 } | |
| { "objects": [ { "name": "Object 1", "set": true }] } | { "objects": [ { "name": "Object 1", "set": true },{ "name": "Object 2", "set": false, "age": 400 }] } | |
| String to match | Matcher value | Match |
|---|---|---|
| { "objects": [ { "name": "Object 1", "set": true }] } | $.objects | |
| { "name": "Object 1", "set": true } | $.objects | |
| { "objects": [ { "name": "Object 1", "set": true }] } | $.objects[1].name | |
| { "objects": [ { "name": "Object 1", "set": true }, { "name": "Object 2", "set": false }] } | $.objects[1].name | |