refactor: remove legacy /shop and /api/v1/shop dead code

After the storefront migration, no live routes mount under /api/v1/shop/.
Remove all dead code that detected/handled shop API requests: the
is_shop_api_request() method, the shop API dispatch branch in middleware,
the RequestContext.SHOP enum member (renamed to STOREFRONT), legacy path
prefixes in FrontendDetector, and all associated tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 13:16:43 +01:00
parent 874e254c11
commit 9173448645
10 changed files with 76 additions and 333 deletions

View File

@@ -26,7 +26,7 @@ from main import app
from tests.integration.middleware.middleware_test_routes import (
admin_router,
api_router,
shop_router,
storefront_router,
store_router,
)
from tests.integration.middleware.middleware_test_routes import (
@@ -39,7 +39,7 @@ if not any(r.path.startswith("/middleware-test") for r in app.routes if hasattr(
app.include_router(api_router)
app.include_router(admin_router)
app.include_router(store_router)
app.include_router(shop_router)
app.include_router(storefront_router)
@pytest.fixture

View File

@@ -10,7 +10,7 @@ IMPORTANT: Routes are organized by prefix to avoid conflicts:
- /api/middleware-test/* - API context testing
- /admin/middleware-test/* - Admin context testing
- /store/middleware-test/* - Store dashboard context testing
- /shop/middleware-test/* - Shop context testing
- /storefront/middleware-test/* - Storefront context testing
"""
from fastapi import APIRouter, Request
@@ -531,15 +531,15 @@ async def test_store_dashboard_theme(request: Request):
# =============================================================================
# Shop Context Test Router
# Storefront Context Test Router
# =============================================================================
shop_router = APIRouter(prefix="/shop/middleware-test")
storefront_router = APIRouter(prefix="/storefront/middleware-test")
@shop_router.get("/context")
async def test_shop_context(request: Request):
"""Test shop context detection."""
@storefront_router.get("/context")
async def test_storefront_context(request: Request):
"""Test storefront context detection."""
context_type = getattr(request.state, "context_type", None)
store = getattr(request.state, "store", None)
theme = getattr(request.state, "theme", None)
@@ -552,9 +552,9 @@ async def test_shop_context(request: Request):
}
@shop_router.get("/custom-domain-context")
async def test_shop_custom_domain_context(request: Request):
"""Test shop context with custom domain."""
@storefront_router.get("/custom-domain-context")
async def test_storefront_custom_domain_context(request: Request):
"""Test storefront context with custom domain."""
context_type = getattr(request.state, "context_type", None)
store = getattr(request.state, "store", None)
return {
@@ -564,9 +564,9 @@ async def test_shop_custom_domain_context(request: Request):
}
@shop_router.get("/theme")
async def test_shop_theme(request: Request):
"""Test theme in shop context."""
@storefront_router.get("/theme")
async def test_storefront_theme(request: Request):
"""Test theme in storefront context."""
context_type = getattr(request.state, "context_type", None)
theme = getattr(request.state, "theme", None)
colors = theme.get("colors", {}) if theme else {}