Skip to content

lang_tools.webapp.api.v1.api_router

API v1 main router aggregating all v1 routes.

Functions:

api_root async

api_root() -> MessageResponse

Return API v1 root information.

Returns:

  • MessageResponse

    MessageResponse with API info.

Source code in src/lang_tools/webapp/api/v1/api_router.py
@router.get(
    "/",
    summary="API v1 root",
    description="Returns API version information.",
)
async def api_root() -> MessageResponse:
    """Return API v1 root information.

    Returns:
        MessageResponse with API info.
    """
    return MessageResponse(message="Lang Tools API v1")

protected_endpoint async

protected_endpoint(
    session: Annotated[
        SessionData, Depends(get_current_user)
    ],
) -> MessageResponse

Return a protected endpoint greeting.

Parameters:

  • session (Annotated[SessionData, Depends(get_current_user)]) –

    Current user session (requires authentication).

Returns:

  • MessageResponse

    MessageResponse with personalized greeting.

Source code in src/lang_tools/webapp/api/v1/api_router.py
@router.get(
    "/protected",
    summary="Protected endpoint example",
    description="Example of an endpoint that requires authentication.",
)
async def protected_endpoint(
    session: Annotated[SessionData, Depends(get_current_user)],
) -> MessageResponse:
    """Return a protected endpoint greeting.

    Args:
        session: Current user session (requires authentication).

    Returns:
        MessageResponse with personalized greeting.
    """
    return MessageResponse(message=f"Hello, {session.name}! You are authenticated.")