REFACTOR ALL APIs fix 1
This commit is contained in:
@@ -300,6 +300,16 @@ async def proxy_tenant_recipes_with_path(request: Request, tenant_id: str = Path
|
||||
target_path = f"/api/v1/tenants/{tenant_id}/recipes/{path}".rstrip("/")
|
||||
return await _proxy_to_recipes_service(request, target_path, tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# TENANT-SCOPED POS SERVICE ENDPOINTS
|
||||
# ================================================================
|
||||
|
||||
@router.api_route("/{tenant_id}/pos/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
|
||||
async def proxy_tenant_pos(request: Request, tenant_id: str = Path(...), path: str = ""):
|
||||
"""Proxy tenant POS requests to POS service"""
|
||||
target_path = f"/api/v1/tenants/{tenant_id}/pos/{path}".rstrip("/")
|
||||
return await _proxy_to_pos_service(request, target_path, tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# PROXY HELPER FUNCTIONS
|
||||
# ================================================================
|
||||
@@ -348,6 +358,10 @@ async def _proxy_to_recipes_service(request: Request, target_path: str, tenant_i
|
||||
"""Proxy request to recipes service"""
|
||||
return await _proxy_request(request, target_path, settings.RECIPES_SERVICE_URL, tenant_id=tenant_id)
|
||||
|
||||
async def _proxy_to_pos_service(request: Request, target_path: str, tenant_id: str = None):
|
||||
"""Proxy request to POS service"""
|
||||
return await _proxy_request(request, target_path, settings.POS_SERVICE_URL, tenant_id=tenant_id)
|
||||
|
||||
async def _proxy_request(request: Request, target_path: str, service_url: str, tenant_id: str = None):
|
||||
"""Generic proxy function with enhanced error handling"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user