mirror of
https://github.com/etesync/server
synced 2024-11-16 05:48:59 +00:00
16 lines
389 B
Python
16 lines
389 B
Python
|
import msgpack
|
||
|
|
||
|
from rest_framework.renderers import BaseRenderer
|
||
|
|
||
|
|
||
|
class MessagePackRenderer(BaseRenderer):
|
||
|
media_type = 'application/msgpack'
|
||
|
format = 'msgpack'
|
||
|
render_style = 'binary'
|
||
|
charset = None
|
||
|
|
||
|
def render(self, data, media_type=None, renderer_context=None):
|
||
|
if data is None:
|
||
|
return b''
|
||
|
return msgpack.packb(data, use_bin_type=True)
|