athena-framework / athena

An ecosystem of reusable, independent components
https://athenaframework.org
MIT License
211 stars 17 forks source link

Scoped URL Matchers #467

Open Blacksmoke16 opened 1 week ago

Blacksmoke16 commented 1 week ago

Currently when you ART.compile a route collection, it populates a singular type which means future calls to it will override the routes stored therein. The major limitation of this is it prevents having more than a single router. I.e. you couldn't use it internally without affecting the core application's routes. Or someone using ART::RoutingHandler couldn't be used within an Athena proper application as the routes would conflict.

I'd like to improve this aspect by providing a way to scope routing to specific route collections. Which could be done in a few different ways:

  1. Provide a new matcher type that doesn't compile the routes, but instead just accepts an ART::RouteCollection
  2. Same as 1, but make it the default and have the compiled matcher be its own thing
  3. Move the ART::RouteProvider concept into the public API to allow compiling the routes into a specific namespace.

I'm leaning towards 3 as it's more performant and most likely easiest to implement since you wouldn't need the route collection in hand at all times.