A redactor is a function that alters the response content being written
out in the capture_requests()
context, allowing you to remove sensitive
values, such as authentication tokens,
as well as any other modification or truncation of the response body. By
default, the redact_auth()
function will be used to purge standard
auth methods, but set_redactor()
allows you to provide a different one.
set_redactor(FUN)
Invisibly, the redacting function, validated and perhaps modified.
Formulas and function lists are turned into proper functions. NULL
as input
returns the force()
function.
A function or expression that modifies response
objects.
Specifically, a valid input is one of:
A function taking a single argument, the response
, and returning a valid
response
object.
A formula as shorthand for an anonymous function with .
as the
"response" argument, as in the purrr
package. That is, instead of
function (response) redact_headers(response, "X-Custom-Header")
, you can
use ~ redact_headers(., "X-Custom-Header")
A list of redacting functions/formulas, which will be executed in sequence on the response
NULL
, to override the default redact_auth()
.
Alternatively, you can put a redacting function in inst/httptest/redact.R
in your package, and
any time your package is loaded (as in when running tests or building
vignettes), the function will be used automatically.
For further details on how to redact responses, see vignette("redacting")
.
set_requester()