openfoodfacts_proxy.routes.v2.reference
[docs]
module
openfoodfacts_proxy.routes.v2.reference
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | from fastapi import APIRouter, Request
from fastapi.responses import Response
from openfoodfacts_proxy.core.application_container import ApplicationContainer
from openfoodfacts_proxy.routes.common import ALL_HTTP_METHODS
router = APIRouter()
@router.get("/api/v2/attribute_groups")
async def attribute_groups(request: Request) -> Response:
return await ApplicationContainer.from_app(request.app).v2_reference_get_handler.handle(request)
@router.get("/api/v2/preferences")
async def preferences(request: Request) -> Response:
return await ApplicationContainer.from_app(request.app).v2_reference_get_handler.handle(request)
@router.get("/api/v2/taxonomy")
async def taxonomy(request: Request) -> Response:
return await ApplicationContainer.from_app(request.app).v2_reference_get_handler.handle(request)
@router.api_route("/api/v2/{path:path}", methods=ALL_HTTP_METHODS, include_in_schema=False)
async def redirect_unhandled_v2(request: Request, path: str) -> Response:
del path
container = ApplicationContainer.from_app(request.app)
if request.method.upper() == "GET":
return await container.v2_reference_get_handler.handle(request)
return await container.v2_passthrough_handler.handle(request)
|