ADD init routers

main
Сергей Ванюшкин 2024-08-19 08:15:02 +00:00
parent 7b68436a7e
commit 736cd533ec
4 changed files with 30 additions and 8 deletions

View File

@ -1,6 +1,20 @@
from fastapi import FastAPI from fastapi import APIRouter, FastAPI
from fastfood_two.routers.dish import router as dish_router
from fastfood_two.routers.menu import router as menu_router
from fastfood_two.routers.submenu import router as submenu_router
from fastfood_two.routers.summary import router as summary_router
def init_routers(app: FastAPI) -> None: def init_routers(app: FastAPI) -> None:
"""Initialize FastAPI routers.""" """Initialize FastAPI routers."""
pass base_router = APIRouter(
prefix="/api/v1",
)
base_router.include_router(menu_router)
base_router.include_router(submenu_router)
base_router.include_router(dish_router)
base_router.include_router(summary_router)
app.include_router(base_router)

View File

@ -1,8 +1,8 @@
from fastapi import APIRouter from fastapi import APIRouter
router = APIRouter(prefix="/dish", tags=["Dish"]) router = APIRouter(prefix="/{menu_id}/submenu/{submenu_id}/dish", tags=["Dish"])
@router.get("/") @router.get("/")
async def get_dishes(): async def get_dishes(menu_id, submenu_id):
return return menu_id, submenu_id

View File

@ -1,8 +1,8 @@
from fastapi import APIRouter from fastapi import APIRouter
router = APIRouter(prefix="/submenu", tags=["Dish"]) router = APIRouter(prefix="/{menu_id}/submenu", tags=["Submenu"])
@router.get("/") @router.get("/")
async def get_dish(): async def get_submenu(menu_id):
return return menu_id

View File

@ -0,0 +1,8 @@
from fastapi import APIRouter
router = APIRouter(prefix="/summary", tags=["Summary"])
@router.get("/")
async def get_summary():
return