#include <protobuf.hpp>
Static Public Member Functions | |
| static std::string_view | mediaType () noexcept |
| template<anch::codec::ProtobufMessage T> | |
| static void | serialize (const T &value, std::ostream &out, anch::codec::Side side) |
| template<anch::codec::ProtobufMessage T> | |
| static void | deserialize (T &value, std::istream &input, anch::codec::Side side) |
| static std::string | toJson (const google::protobuf::Message &message) |
| static void | fromJson (google::protobuf::Message &message, std::string_view json, bool ignoreUnknownFields) |
application/json codec for protoc messages: Protocol Buffers JSON mapping (field names in lowerCamelCase, 64 bits integers as strings, ...). Unknown fields are refused on server side and ignored on client side (server responses are trusted). Invalid messages raise std::invalid_argument ( 400 on server side).
|
static |
Read message
| value | the message to fill |
| input | the input stream |
| side | the side which reads message |
| std::invalid_argument | when message is invalid |
| ContentTooLarge | when body is larger than maxBodySize |
|
static |
Read message from JSON
| message | the message to fill |
| json | the JSON text |
| ignoreUnknownFields | ignore unknown fields |
| std::invalid_argument | when JSON is not a valid message |
|
staticnoexcept |
Media type
application/json
|
static |
Write message
| value | the message |
| out | the output stream |
| side | the side which writes message |
| std::runtime_error | when message can not be written |
|
static |
Get JSON of a message
| message | the message |
| std::runtime_error | when message can not be written |