Protocol Buffers filter and serializer for Plumber.
The ProtoBuf filter will unserialize ProtoBuf messages according
to the messagetype
set in the request header
(e.g. Content-Type: application/x-protobuf; messagetype=prototest.TestPayload
),
and matching a .proto
descriptor file.
The ProtoBuf serializer serializes an RProtoBuf message descriptor object, adding the type of message to the response header.
protopretzel
is under active development and things may break. Check out the protopretzel-playground for an example implementation.
You can install the current development version of protopretzel with:
# install.packages("devtools")
devtools::install_github("ozean12/protopretzel")
library(plumber)
library(protopretzel)
# Needs to be added before API creation
addProtobufSerializer()
api <- plumber$new("api.R")
addProtobufFilter(api, descriptor_path = "prototest.proto")
api$run(host = "0.0.0.0", port = 8000)