apifrom.core.routerο
Router module for APIFromAnything.
This module defines the Router class that manages the registration and lookup of API endpoints.
Overviewο
Classes
Functions
Classesο
Router for managing API endpoints.
- apifrom.core.router.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.
- apifrom.core.router.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.
- apifrom.core.router.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ο
- apifrom.core.router.get_type_hints_with_extras(obj)[source]ο
- Parameters:
obj (Callable)
- Return type:
Dict[str, Type]
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.