vignettes/files/apis/07-04-file-safe.R

#* This is an example of an endpoint which
#* checks user input.
#* @get /
function(file) {
  # Strip all "non-word" characters from user input
  sanitizedFile <- gsub("\\W", "", file)

  path <- file.path("./datasets", sanitizedFile)
  readLines(path)
}
trestletech/plumber documentation built on May 6, 2024, 6:17 p.m.