set_redactor | R Documentation |
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.
set_redactor(FUN)
FUN |
A function or expression that modifies
|
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.
Invisibly, the redacting function, validated and perhaps modified.
Formulas and function lists are turned into proper functions. NULL
as input
returns the force()
function.
For further details on how to redact responses, see vignette("redacting", package = "httptest2")
.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.