Router::Right — advanced URL router in Raku
Framework-agnostic URL routing engine for web applications in Raku.
Synopsys
use v6.d;
use Router::Right;
my $route = Router::Right.new;
$route.add(
:name( 'dynaroute' ),
:path( 'GET /dynamic/{id:<[\d]>+}/{tag}/{item}' ),
:payload( 'Dynamic#Route' ),
);
if !(
my %m = $route.match(
%*ENV<REQUEST_URI> || ~(),
)
) {
say $route.error;
}
else {
say %m.gist;
}
Wiki
Full documentation is available on Raku Router::Right wiki pages.
Methods
new() — returns a new Router::Right instance;
add() — defines a new route;
match() — attempts to find a route that matches the supplied path (URL);
error() — returns the error code of the last failed match;
allowed_methods() — returns the array of allowed methods for a given route;
url() — constructs a URL from the route;
as_string() — returns a report of the defined routes, in order of definition;
with() — helper method to share information across multiple routes;
resource() — adds routes to create, read, update, and delete a given resource;
route() — returns route details hash.
Examples
Hello, world! — simple router;
Trick with resources — populate resources with nested with() call;
License
Raku Router::Right is free and opensource software, so you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
Author
Please contact me via LinkedIn or Twitter. Your feedback is welcome at narkhov.pro.
Perl5 Router::Right
Github
Author