set_redactor {httptest2} | R Documentation |
Set a response redactor
Description
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_cookies()
function will be used to purge standard
auth methods, but set_redactor()
allows you to provide a different one.
Usage
set_redactor(FUN)
Arguments
FUN |
A function or expression that modifies
|
Details
Alternatively, you can put a redacting function in inst/httptest2/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.
Value
Invisibly, the redacting function, validated and perhaps modified.
Formulas and function lists are turned into proper functions. NULL
as input
returns the force()
function.
See Also
For further details on how to redact responses, see vignette("redacting", package = "httptest2")
.
Examples
# Shorten UUIDs in response body/URLs to their first 6 digits:
set_redactor(function(resp) gsub_response(resp, "([0-9a-f]{6}[0-9a-f]{26}", "\\1"))
# Restore the default
set_redactor(redact_cookies)