mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-12-01 22:14:04 +03:00
Fix 204 content-leength error
This commit is contained in:
parent
6270b88caf
commit
d0899cb393
|
@ -22,13 +22,12 @@ def get_list(
|
||||||
@inject
|
@inject
|
||||||
def get_by_id(
|
def get_by_id(
|
||||||
user_id: int,
|
user_id: int,
|
||||||
response: Response,
|
|
||||||
user_service: UserService = Depends(Provide[Container.user_service]),
|
user_service: UserService = Depends(Provide[Container.user_service]),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
return user_service.get_user_by_id(user_id)
|
return user_service.get_user_by_id(user_id)
|
||||||
except NotFoundError:
|
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)
|
@router.post('/users', status_code=status.HTTP_201_CREATED)
|
||||||
|
@ -43,13 +42,14 @@ def add(
|
||||||
@inject
|
@inject
|
||||||
def remove(
|
def remove(
|
||||||
user_id: int,
|
user_id: int,
|
||||||
response: Response,
|
|
||||||
user_service: UserService = Depends(Provide[Container.user_service]),
|
user_service: UserService = Depends(Provide[Container.user_service]),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
user_service.delete_user_by_id(user_id)
|
user_service.delete_user_by_id(user_id)
|
||||||
except NotFoundError:
|
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')
|
@router.get('/status')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user