Closed dominikzogg closed 3 years ago
This is something a bit tricky, it's not supported by hack-router, and unlikely to be added here first.
currently, there's 2 ways to do this, but 1 is not possible with "string" pattern, and the other is complicated and slow.
UriPattern
instead of AbstractRouter/Routersee: https://github.com/azjezz/hack-routing/blob/main/examples/UriPatternsExample.php
I already did this in hacklang, which you can see here: https://github.com/nuxed/http-router/blob/develop/src/Nuxed/Http/Router/Generator/UriGenerator.hack, but this code is old, slow, and probably not perfect, so you might need to optimize it a bit.
Similar to what I did in the given link. Thanks!
you should probably use the same cache to cache the parsed data. as that step is usually slow.
Is your feature request related to a problem? Please describe. No problem,
Describe the solution you'd like I would love to be able generate a path from a pattern and an array for the variable parts. Something like: https://github.com/chubbyphp/chubbyphp-framework-router-hack-routing/blob/master/src/UrlGenerator.php
Describe alternatives you've considered The alternative would be keep the custom implementation as mentioned in describe the solution
Additional context Add any other context or screenshots about the feature request here.