register_serializer | R Documentation |
A serializer is responsible for translating a generated R value into output
that a remote user can understand. For instance, the serializer_json
serializes R objects into JSON before returning them to the user. The list of
available serializers in plumber is global.
register_serializer(name, serializer, verbose = TRUE) registered_serializers()
name |
The name of the serializer (character string) |
serializer |
The serializer function to be added.
This function should accept arguments that can be supplied when |
verbose |
Logical value which determines if a message should be printed when overwriting serializers |
There are three main building-block serializers:
serializer_headers
: the base building-block serializer that is required to have as_attachment()
work
serializer_content_type()
: for setting the content type. (Calls serializer_headers()
)
serializer_device()
: add endpoint hooks to turn a graphics device on and off in addition to setting the content type. (Uses serializer_content_type()
)
register_serializer()
: Register a serializer with a name
registered_serializers()
: Return a list of all registered serializers
# `serializer_json()` calls `serializer_content_type()` and supplies a serialization function print(serializer_json) # serializer_content_type() calls `serializer_headers()` and supplies a serialization function print(serializer_content_type)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.