Performance: Router prefix and tags
LOW IMPACT
This concept affects the initial server response time and the clarity of API documentation loading, impacting how quickly clients can discover and interact with endpoints.
from fastapi import FastAPI, APIRouter app = FastAPI() user_router = APIRouter(prefix="/users", tags=["users"]) @user_router.get("") def get_users(): return [{"name": "Alice"}] item_router = APIRouter(prefix="/items", tags=["items"]) @item_router.get("") def get_items(): return [{"item": "Book"}] app.include_router(user_router) app.include_router(item_router)
from fastapi import FastAPI app = FastAPI() @app.get("/users") def get_users(): return [{"name": "Alice"}] @app.get("/items") def get_items(): return [{"item": "Book"}]
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No router prefixes or tags | N/A | N/A | N/A | [!] OK |
| Using router prefixes and tags | N/A | N/A | N/A | [OK] Good |