From b971a5254be3d6db654b551519e8236f8fdf991a Mon Sep 17 00:00:00 2001 From: Benjamin Bolte Date: Wed, 29 May 2024 16:01:54 -0400 Subject: [PATCH] http 404 endpoint --- store/app/api/routers/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/store/app/api/routers/main.py b/store/app/api/routers/main.py index 7f3aac51..e65a241f 100644 --- a/store/app/api/routers/main.py +++ b/store/app/api/routers/main.py @@ -2,7 +2,7 @@ import logging -from fastapi import APIRouter +from fastapi import APIRouter, HTTPException, status from store.app.api.routers.users import users_router @@ -11,3 +11,9 @@ api_router = APIRouter() api_router.include_router(users_router, prefix="/users", tags=["users"]) + + +# Returns a 404 response for all other paths. +@api_router.get("/{path:path}") +async def not_found(path: str) -> dict[str, str]: + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Endpoint not found")