rawleyfowler / Humming-Bird

A fun and performant web application framework for Raku
MIT License
44 stars 6 forks source link

Add express style routers #37

Closed rawleyfowler closed 1 year ago

rawleyfowler commented 1 year ago

I think it would be nice to be able to construct routers, this would be an OO style route declaration, that would provide the basis for more simpler grouping, and separation of concerns.

rawleyfowler commented 1 year ago

This would look something like:

use Humming-Bird::Core;

my $router = Router.new(root => '/foo');

# This will register a route at /foo/bar
$router.get('/bar', -> $request, $response { $response.write('Foo bar!') });

# This will register this middleware for all routes in this router
$router.middleware(&middleware-logger);

# This will register this advice for all routes in this router
$router.advice(&advice-logger);