python_template_server.routers.base_router

Base router for the FastAPI server.

Classes

BaseRouter(prefix)

Abstract base class for API routers.

class python_template_server.routers.base_router.BaseRouter(prefix)[source]

Abstract base class for API routers.

__init__(prefix)[source]

Initialize the base router.

abstractmethod setup_routes()[source]

Abstract method to set up API routes.

Return type:

None

configure(hashed_token, limiter, rate_limit)[source]

Configure the router with shared dependencies.

Parameters:
  • hashed_token (str) – The hashed token for API key verification

  • limiter (Limiter | None) – The rate limiter instance to use for this router

  • rate_limit (str) – The rate limit string to apply to limited routes

Return type:

None

add_route(endpoint, handler_function, response_model, methods, limited, authentication_required)[source]

Add an API route.

Parameters:
  • endpoint (str) – The API endpoint path

  • handler_function (Callable) – The handler function for the endpoint

  • response_model (type[BaseModel] | None) – The Pydantic model for the response

  • methods (list[str]) – The HTTP methods for the endpoint

  • limited (bool) – Whether to apply rate limiting to this route

  • authentication_required (bool) – Whether authentication is required for this route

Return type:

None