including | R Documentation |
For use inside wi_th()
including(x)
excluding(x)
x |
(list) a list; may support other classes in the future |
same as x
, but with two attributes added:
partial_match: always TRUE
partial_type: the type of match, one of include
or exclude
Matching on headers already handles partial matching. That is,
wi_th(headers = list(Fruit = "pear"))
matches any request
that has any request header that matches - the request can have
other request headers, but those don't matter as long as there is
a match. These helpers (including
/excluding
) are needed
for query parameters and bodies because by default matching must be
exact for those.
including(list(foo = "bar"))
excluding(list(foo = "bar"))
# get just keys by setting values as NULL
including(list(foo = NULL, bar = NULL))
# in a stub
req <- stub_request("get", "https://httpbin.org/get")
req
## query
wi_th(req, query = list(foo = "bar"))
wi_th(req, query = including(list(foo = "bar")))
wi_th(req, query = excluding(list(foo = "bar")))
## body
wi_th(req, body = list(foo = "bar"))
wi_th(req, body = including(list(foo = "bar")))
wi_th(req, body = excluding(list(foo = "bar")))
# cleanup
stub_registry_clear()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.