(result: Any, status_code: HTTPStatus = HTTPStatus.OK)
| 22 | |
| 23 | |
| 24 | def api_response(result: Any, status_code: HTTPStatus = HTTPStatus.OK) -> Response: |
| 25 | if status_code == HTTPStatus.NO_CONTENT: |
| 26 | assert not result, "Provided 204 response with non-zero length response" |
| 27 | data = "" |
| 28 | else: |
| 29 | data = json.dumps(result) |
| 30 | |
| 31 | log.debug("Request successful", response=result, status_code=status_code) |
| 32 | response = make_response( |
| 33 | (data, status_code, {"mimetype": "application/json", "Content-Type": "application/json"}) |
| 34 | ) |
| 35 | return response |
| 36 | |
| 37 | |
| 38 | def api_error(errors: Any, status_code: HTTPStatus) -> Response: |
no test coverage detected