This commit is contained in:
yumoqing 2023-08-05 16:41:27 +08:00
parent d8eecb43c3
commit 36c86520f0

View File

@ -90,17 +90,26 @@ class BaseProcessor(AppLogger):
async def handle(self,request): async def handle(self,request):
await self.execute(request) await self.execute(request)
jsonflg = False
if self.retResponse is not None: if self.retResponse is not None:
self.set_response_headers(self.retResponse) self.set_response_headers(self.retResponse)
return self.retResponse return self.retResponse
elif type(self.content) == type({}) : elif type(self.content) == type({}) :
self.content = json.dumps(self.content, self.content = json.dumps(self.content, indent=4)
indent=4) jsonflg = True
elif type(self.content) == type([]): elif type(self.content) == type([]):
self.content = json.dumps(self.content, self.content = json.dumps(self.content, indent=4)
indent=4) jsonflg = True
else:
try:
json.loads(self.content)
jsonflg = True
except:
pass
if jsonflg:
self.headers['Content-Type'] = "application/json; utf-8" self.headers['Content-Type'] = "application/json; utf-8"
self.headers['Access-Control-Expose-Headers'] = 'Set-Cookie' self.headers['Access-Control-Expose-Headers'] = 'Set-Cookie'
resp = Response(text=self.content,headers=self.headers) resp = Response(text=self.content,headers=self.headers)
self.set_response_headers(resp) self.set_response_headers(resp)