Skip to content

openfoodfacts_proxy.routes.v3.reference

[docs] module openfoodfacts_proxy.routes.v3.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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/v3/taxonomy_canonicalize_tags")
async def taxonomy_canonicalize_tags(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).v3_reference_get_handler.handle(request)


@router.get("/api/v3/taxonomy_display_tags")
async def taxonomy_display_tags(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).v3_reference_get_handler.handle(request)


@router.get("/api/v3/taxonomy_suggestions")
async def taxonomy_suggestions(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).v3_reference_get_handler.handle(request)


@router.post("/api/v3/product_revert")
async def product_revert(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).documented_write_handler.handle_product_revert(request)


@router.patch("/api/v3/product/test")
async def parse_ingredients(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).documented_write_handler.handle_parse_ingredients(request)


@router.get("/api/v3/external_sources")
async def external_sources(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).v3_reference_get_handler.handle(request)


@router.get("/api/v3/preferences")
async def preferences(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).v3_reference_get_handler.handle(request)


@router.get("/api/v3.4/attribute_groups")
async def attribute_groups_v34(request: Request) -> Response:
    return await ApplicationContainer.from_app(request.app).v3_reference_get_handler.handle(request)


@router.api_route("/api/v3/{path:path}", methods=ALL_HTTP_METHODS, include_in_schema=False)
async def redirect_unhandled_v3(request: Request, path: str) -> Response:
    del path
    container = ApplicationContainer.from_app(request.app)
    if request.method.upper() == "GET":
        return await container.v3_reference_get_handler.handle(request)
    return await container.v3_passthrough_handler.handle(request)


@router.api_route("/api/v3.4/{path:path}", methods=ALL_HTTP_METHODS, include_in_schema=False)
async def redirect_unhandled_v34(request: Request, path: str) -> Response:
    del path
    container = ApplicationContainer.from_app(request.app)
    if request.method.upper() == "GET":
        return await container.v3_reference_get_handler.handle(request)
    return await container.v3_passthrough_handler.handle(request)