v2.4.3 - route prefix group + improvements!
👋 Aloha! We had a couple feature/improvement bumps and a few bug/misc fixes since the last release, so this one should be pretty stacked.
- Added route grouping, starting with route prefixes!
- Cleaned up routing and basePath/root route handling via new route trimming
- Fixed the route parameter constraint overlap bug!
Route Prefixes
As mentioned back in #3 and #10, we wanted a way to serve a specific "base path" without another entrypoint/router. To do this, we came up with a simple but clever solution; route grouping! Similar to how Laravel's routing works, you only need to provide a prefix and a function that registers new routes!
Router::prefix('api', function () {
Router::get('/foo', function () { return "foo"; });
Router::get('/bar/{name}', function ($name) {
return "$name is at the bar.";
})->with('name', '[A-Za-z]+');
});Have fun with it!