Skip to content

Commit

Permalink
chore: add error detail on GET request
Browse files Browse the repository at this point in the history
Add a new route handler for handling GET requests for the `/general/v0/general`. This handler will return the error message that informs user that GET request is not permitted.
  • Loading branch information
Klaijan authored Jan 17, 2024
1 parent be06ddf commit e8df505
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions prepline_general/api/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,14 @@ def return_content_type(filename):
)


@router.get("/general/v0/general")
@router.get("/general/v0.0.62/general")
async def handle_invalid_get_request():
raise HTTPException(
status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Only POST requests are supported."
)


@router.post("/general/v0/general")
@router.post("/general/v0.0.62/general")
def pipeline_1(
Expand Down
7 changes: 7 additions & 0 deletions test_general/api/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,3 +918,10 @@ def test_invalid_hi_res_model_name_returns_400():
)
assert response.status_code == 400
assert "Unknown model type" in response.text


def test_get_request():
client = TestClient(app)
response = client.get("/general/v0/general")
assert response.status_code == 405
assert response.json() == {"detail": "Only POST requests are supported."}

0 comments on commit e8df505

Please sign in to comment.