Refactor request data handling and update unit tests

This commit is contained in:
sHa
2024-03-22 09:26:15 +02:00
parent 367603a0d6
commit 81bb8398f0
4 changed files with 47 additions and 18 deletions

View File

@@ -21,13 +21,24 @@ class CatchController(BaseController):
try:
json = await request.json()
except Exception:
json = {"invalid": "json"}
json = None
try:
form = await request.form()
except Exception:
form = None
http_version = request.scope.get("http_version")
last_request = {
"data": json,
"method": request.method,
"data": json,
"params": dict(request.query_params),
"form": form,
"url": str(request.url),
"headers": dict(request.headers),
"cookies": dict(request.cookies),
"http_version": http_version,
"time": datetime.now().isoformat(),
}
history = History(namespace)