Skip to content

Commit 819db5f

Browse files
re-arrange log_router
1 parent 88f664b commit 819db5f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/SearchAPI/application/log_router.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@ async def custom_route_handler(request: Request) -> Response:
5050
try:
5151
response: Response = await original_route_handler(request)
5252
finally:
53+
queryBody = {}
54+
if (content_type := request.headers.get('content-type')) is not None:
55+
if content_type == 'application/json':
56+
queryBody = await request.json()
5357
# What to ALWAYS log:
5458
duration = time.time() - before
5559
api_logger.info(
5660
"Query finished running.",
5761
extra={
5862
"QueryTime": duration,
5963
"QueryParams": dict(request.query_params),
60-
"QueryBody": dict(await request.json()),
64+
"QueryBody": queryBody,
6165
"Endpoint": request.scope['path'],
6266
}
6367
)

0 commit comments

Comments
 (0)