function(pts=10) {
if (pts > 1000){
stop("pts must be < 1,000")
}
plot(1:pts)
}
function(file) {
sanitizedFile <- gsub("\\W", "", file)
path <- file.path("./datasets", sanitizedFile)
readLines(path)
}
safeCharVector <- htmltools::html_escape(charVector)
#* @filter cors
cors <- function(res) {
res$setHeader("Access-Control-Allow-Origin", "*")
plumber::forward()
}
#* @preempt cors
#* @get /sub
cors_disabled <- function(a, b){
as.numeric(a) - as.numeric(b)
}
Source of content: Jeff Allen | Trestletech | Creating API’s in R Plumber | Chapter 6 Security