Fix errors in log with 204 response endpoints.

FastAPI uses JsonResponse by default, which will convert the empty
response None to null. We need to forcibly use Response instead to
prevent that for No Content responses.

This didn't cause any observable issues but was polluting the log.
This commit is contained in:
Dan Albert
2022-10-07 14:33:15 -07:00
committed by Raffson
parent 07425ea04f
commit 1606534862
2 changed files with 5 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ from uuid import UUID
from dcs import Point
from dcs.mapping import LatLng
from fastapi import APIRouter, Body, Depends, HTTPException, status
from starlette.responses import Response
from game import Game
from .models import ControlPointJs
@@ -59,6 +60,7 @@ def destination_in_range(
"/{cp_id}/destination",
operation_id="set_control_point_destination",
status_code=status.HTTP_204_NO_CONTENT,
response_class=Response,
)
def set_destination(
cp_id: UUID,
@@ -98,6 +100,7 @@ def set_destination(
"/{cp_id}/cancel-travel",
operation_id="clear_control_point_destination",
status_code=status.HTTP_204_NO_CONTENT,
response_class=Response,
)
def cancel_travel(cp_id: UUID, game: Game = Depends(GameContext.require)) -> None:
cp = game.theater.find_control_point_by_id(cp_id)