You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
436 B
Python
15 lines
436 B
Python
import msgpack
|
|
|
|
from rest_framework.parsers import BaseParser
|
|
from rest_framework.exceptions import ParseError
|
|
|
|
|
|
class MessagePackParser(BaseParser):
|
|
media_type = "application/msgpack"
|
|
|
|
def parse(self, stream, media_type=None, parser_context=None):
|
|
try:
|
|
return msgpack.unpackb(stream.read(), raw=False)
|
|
except Exception as exc:
|
|
raise ParseError("MessagePack parse error - %s" % str(exc))
|