From 7f90edc5114b50fa2ad414a4f2abc18f263fbdf4 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 27 Dec 2020 21:01:14 +0200 Subject: [PATCH] MsgPack: handle no content. --- etebase_fastapi/msgpack.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etebase_fastapi/msgpack.py b/etebase_fastapi/msgpack.py index 399f3d0..edffd7e 100644 --- a/etebase_fastapi/msgpack.py +++ b/etebase_fastapi/msgpack.py @@ -19,7 +19,10 @@ class MsgpackRequest(Request): class MsgpackResponse(Response): media_type = "application/msgpack" - def render(self, content: t.Any) -> bytes: + def render(self, content: t.Optional[t.Any]) -> t.Optional[bytes]: + if content is None: + return b"" + if isinstance(content, BaseModel): content = content.dict() return msgpack.packb(content, use_bin_type=True)