tests/testthat/files/entrypoint/entrypoint.R

plumber::register_serializer("fake", function(){
  function(val, req, res, errorHandler){
    tryCatch({
      json <- jsonlite::toJSON(val)

      res$setHeader("Content-Type", "application/json")
      res$body <- paste0("FAKE", json)

      return(res$toResponse())
    }, error=function(e){
      errorHandler(req, res, e)
    })
  }
})

pr("./plumber.R")

Try the plumber package in your browser

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

plumber documentation built on Sept. 7, 2022, 1:05 a.m.