register_serializer {plumber}R Documentation

Register a Serializer

Description

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.

Usage

register_serializer(name, serializer, verbose = TRUE)

registered_serializers()

Arguments

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 plumb()ing a file. This function should return a function that accepts four arguments: value, req, res, and errorHandler. See print(serializer_json) for an example.

verbose

Logical value which determines if a message should be printed when overwriting serializers

Details

There are three main building-block serializers:

Functions

Examples

# `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)

[Package plumber version 1.2.2 Index]