| porcelain_endpoint | R Documentation |
Create a porcelain_endpoint object that collects
together an HTTP method (e.g., GET), a path (e.g.,
/path) and a target R function. Unlike plumber
endpoints, porcelain endpoints are meant to be used in testing.
methodHTTP method
pathHTTP path
targetR function used for the endpoint
validateLogical, indicating if response validation is used
inputsInput control
statePossibly mutable state
returningAn porcelain_returning object
controlling the return type (content type, status code,
serialisation and validation information).
new()Create an endpoint
porcelain_endpoint$new(method, path, target, ..., returning, validate = NULL)
methodThe HTTP method to support
pathThe server path for the endpoint
targetAn R function to run as the endpoint
...Additional parameters, currently representing
inputs. You can use the functions
porcelain_input_query,
porcelain_input_body_binary and
porcelain_input_body_json to define inputs and pass
them into this method. The names used must match those in
target.
returningInformation about what the endpoint returns,
as created by porcelain_returning
validateLogical, indicating if any validation
(implemented by the validate_response argument) should
be enabled. This should be set to FALSE in production
environments. By default (if validate is NULL),
we look at the value of the environment PORCELAIN_VALIDATE -
if true (case insensitive) then we will validate.
This is intended to support easy use of validation on
continuous integration systems.
validate_responseOptional function that throws an error of the processed body is "invalid".
run()Run the endpoint. This will produce a
standardised response object that contains status_code,
content_type, body (the serialised output as run
through the process method and returned by plumber) and
data (the result of running the target function)
porcelain_endpoint$run(...)
...Arguments passed through to the target function
request()Test the endpoint. This creates a full plumber
object and serves one request to the endpoint. Argument are as
passed through to porcelain's $request()
method, except that method and path are
automatically taken from the endpoint itself.
porcelain_endpoint$request(...)
...Arguments passed through to the request method
(query, body and content_type).
plumber()Helper method for use with plumber - not designed for end-user use. This is what gets called by plumber when the endpoint receives a request.
porcelain_endpoint$plumber(req, res, ...)
req, resConventional plumber request/response objects
...Additional arguments passed through to run
create()Create a plumber endpoint
porcelain_endpoint$create(envir, validate)
envirEnvironment as used by plumber (currently unclear)
validateLogical, allowing override of validation at the api level. This takes precedence over the value set when creating the endpoint.
clone()The objects of this class are cloneable with this method.
porcelain_endpoint$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.