R/utils-redacted.R

Defines functions is_redacted_sentinel list_redact str.httr2_redacted_sentinel format.httr2_redacted_sentinel print.httr2_redacted_sentinel redacted_sentinel

redacted_sentinel <- function() {
  structure(list(NULL), class = "httr2_redacted_sentinel")
}
#' @export
print.httr2_redacted_sentinel <- function(x, ...) {
  cat(format(x), "\n", sep = "")
  invisible(x)
}
#' @export
format.httr2_redacted_sentinel <- function(x, ...) {
  unclass(cli::col_grey("<REDACTED>"))
}
#' @export
str.httr2_redacted_sentinel <- function(object, ...) {
  cat(" ", cli::col_grey("<REDACTED>"), "\n", sep = "")
}

list_redact <- function(x, names) {
  x[names(x) %in% names] <- list(redacted_sentinel())
  x
}

is_redacted_sentinel <- function(x) {
  inherits(x, "httr2_redacted_sentinel")
}

Try the httr2 package in your browser

Any scripts or data that you put into this service are public.

httr2 documentation built on Aug. 8, 2025, 7:52 p.m.