From d0899cb393e0d62860bd50fd8c19c1ffa57ac148 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Thu, 4 Feb 2021 08:57:08 -0500 Subject: [PATCH] Fix 204 content-leength error --- examples/miniapps/fastapi-sqlalchemy/webapp/endpoints.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/miniapps/fastapi-sqlalchemy/webapp/endpoints.py b/examples/miniapps/fastapi-sqlalchemy/webapp/endpoints.py index c8102948..799e6171 100644 --- a/examples/miniapps/fastapi-sqlalchemy/webapp/endpoints.py +++ b/examples/miniapps/fastapi-sqlalchemy/webapp/endpoints.py @@ -22,13 +22,12 @@ def get_list( @inject def get_by_id( user_id: int, - response: Response, user_service: UserService = Depends(Provide[Container.user_service]), ): try: return user_service.get_user_by_id(user_id) except NotFoundError: - response.status_code = status.HTTP_404_NOT_FOUND + return Response(status_code=status.HTTP_404_NOT_FOUND) @router.post('/users', status_code=status.HTTP_201_CREATED) @@ -43,13 +42,14 @@ def add( @inject def remove( user_id: int, - response: Response, user_service: UserService = Depends(Provide[Container.user_service]), ): try: user_service.delete_user_by_id(user_id) except NotFoundError: - response.status_code = status.HTTP_404_NOT_FOUND + return Response(status_code=status.HTTP_404_NOT_FOUND) + else: + return Response(status_code=status.HTTP_204_NO_CONTENT) @router.get('/status')