Given any Plumber API, for versions of plumber up to 1.1.0:
options(`plumber.sharedSecret`="abcdefg")
plumber::plumb(file='plumber.R')$run()
# On connecting to this application:
# <simpleError in (function (req, res) { secret <- getOption("plumber.sharedSecret", NULL) if (!is.null(secret)) { supplied <- req$HTTP_PLUMBER_SHARED_SECRET if (!identical(supplied, secret)) { res$status <- 400 stop("The provided shared secret did not match expected secret.") } } forward()})(req = <environment>, res = <environment>): The provided shared secret did not match expected secret.>
Interacting with that API gives:
curl http://127.0.0.1:3063/echo
# {"error":"Internal error","message":"Error in (function (req, res) : The provided shared secret did not match expected secret.\n"}
It is not necessary to use stop; returning an error response is sufficient.
Given any Plumber API, for versions of plumber up to 1.1.0:
Interacting with that API gives:
It is not necessary to use
stop; returning an error response is sufficient.