Routing is the heart of the request-to-controller mapping system in Apivalk. It is designed for high performance, ease of use, and zero-configuration through automated discovery.
The Router is initialized with a RouterCacheInterface implementation.
During dispatch, the Router retrieves a RouterCacheCollection from the cache.
The Router iterates through the collection, comparing the current request’s URI against the pre-generated regex patterns for each route.
If a match is found, the Router identifies the associated controller and request classes.
The Router then populates the request object and executes the middleware stack.
By combining documentation-driven route definitions with automated discovery and caching, Apivalk provides a powerful routing system that requires minimal manual intervention.