Closed Som-Som-CC closed 6 months ago
https://github.com/vmihailenco/msgpack/ seems to be a nicely maintained msgpack implementation with SetCustomStructTag
functions.
For large structs it seems to be twice as fast as encoding/json with half the number of allocations (though memory use on a par or even higher) and somewhat more dense binary data. That is what one would expect when reading msgpack specification.
You may ask why MessagePack when there are more popular and snappier protocols. Such as Protobuf, used by gRPC, Connect RPC or Twirp.
There can be many reasons. For example, these are much more than versatile than a RESTful resource manipulation. Protobuf is not a drop-in replacement for JSON, hence its efficiency. And most importantly, these libs provide all the bells and whistles what this restful lib provides.
Ongoing. See https://github.com/nokia/restful/pull/63
MessagePack (a.k.a. msgpack) is a great data interchange format. It is often cited as binary JSON. Flexible like JSON, but more efficient. Not as snappy as Protocol Buffers/gRPC, but more flexible and still fast.
The aim of this enhancement:
Accept
header indicating the server that the client supports msgpack, ifclient.MsgPack(true)
was called.application/msgpack
.application/msgpack
.Accept
header indicates support. Otherwise use JSON.Go standard JSON library uses "json" tagging. The msgpack package chosen must be able to use that tagging for smooth interworking.