MCPcopy Create free account
hub / github.com/dbunt1tled/python-fast-api / extract_body

Function extract_body

src/core/service/functions.py:53–70  ·  view source on GitHub ↗
(request: Request, secure: bool = False, as_dict: bool = False)

Source from the content-addressed store, hash-verified

51
52
53def extract_body(request: Request, secure: bool = False, as_dict: bool = False) -> dict[str, Any] | str:
54 result: dict[str, Any] | str = {} if as_dict else ""
55 if not hasattr(request.state, "body"):
56 return result
57 body = request.state.body
58 if not body:
59 return result
60 body_request = body.decode("utf-8", errors="ignore")
61 try:
62 result = json.loads(body_request)
63 if secure:
64 result = filter_params(result)
65 if not as_dict:
66 result = json.dumps(result, ensure_ascii=False, indent=2)
67 except json.JSONDecodeError:
68 pass
69
70 return result

Callers 1

exception_handlerFunction · 0.90

Calls 1

filter_paramsFunction · 0.85

Tested by

no test coverage detected