(_request: Request, body: dict = Body(...))
| 587 | |
| 588 | def make_view_func(handler, param_names): |
| 589 | async def view_func(_request: Request, body: dict = Body(...)): |
| 590 | kwargs = { |
| 591 | k: v |
| 592 | for k, v in body.items() |
| 593 | if k in param_names and v is not None |
| 594 | } |
| 595 | if inspect.iscoroutinefunction(handler): |
| 596 | result = await handler(**kwargs) |
| 597 | else: |
| 598 | result = handler(**kwargs) |
| 599 | return JSONResponse(content=result) |
| 600 | |
| 601 | return view_func |
| 602 |