apifrom.core.router =================== Router module for APIFromAnything. This module defines the Router class that manages the registration and lookup of API endpoints. .. py:currentmodule:: apifrom.core.router Overview -------- **Classes** * :py:class:`Router` **Functions** * :py:func:`get_type_hints_with_extras` Classes ------- .. py:class:: Router Router for managing API endpoints. This class is responsible for registering and looking up API endpoints. It maintains a registry of routes and their associated handlers. .. attribute:: routes List of registered routes. :type: list Initialize a new Router instance. .. :: routes :no-index: .. method:: add_route(handler, path = None, method = 'GET', name = None, **kwargs) Add a route to the router. :param handler: The function to handle the route. :param path: The URL path for the route. If None, derived from handler name. :param method: The HTTP method for the route. :param name: The name for the route. If None, derived from handler name. :param \*\*kwargs: Additional arguments to associate with the route. .. method:: get_route_by_path(path, method = 'GET') Get a route by path and method. :param path: The path to match. :param method: The HTTP method to match. :returns: The route info if found, None otherwise. .. method:: get_route_handler(path, method = 'GET') Get a route handler by path and method. :param path: The path to match. :param method: The HTTP method to match. :returns: The handler function if found, None otherwise. Functions --------- .. py:function:: get_type_hints_with_extras(obj) Get type hints for a callable, including return type. This function extends typing.get_type_hints to include additional information about the types, such as whether they are optional. :param obj: The callable to get type hints for. :returns: A dictionary mapping parameter names to their types.