You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2021/06/04 10:01:28 UTC
[incubator-ponymail-foal] branch master updated: Simplify by
handling web Response first
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new 0d9e25f Simplify by handling web Response first
0d9e25f is described below
commit 0d9e25f3f7909e81618a6b8fd8468c0ea9f7589a
Author: Sebb <se...@apache.org>
AuthorDate: Fri Jun 4 11:01:16 2021 +0100
Simplify by handling web Response first
---
server/main.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/server/main.py b/server/main.py
index c811cc2..8b8cb0e 100644
--- a/server/main.py
+++ b/server/main.py
@@ -119,13 +119,13 @@ class Server(plugins.server.BaseServer):
self.dbpool.put_nowait(session.database)
self.dbpool.task_done()
session.database = None
+ if isinstance(output, aiohttp.web.Response):
+ return output
headers["content-type"] = "application/json"
- if output and not isinstance(output, aiohttp.web.Response):
+ if output:
jsout = await self.runners.run(json.dumps, output, indent=2)
headers["Content-Length"] = str(len(jsout))
return aiohttp.web.Response(headers=headers, status=200, text=jsout)
- if isinstance(output, aiohttp.web.Response):
- return output
return aiohttp.web.Response(
headers=headers, status=404, text="Content not found"
)