NAME

Mojolicious::Plugin::PlainRoutes - Plaintext route definitions for Mojolicious

VERSION

version 0.07

SYNOPSIS

In lib/MyApp.pm:

sub startup {
...
$self->plugin('PlainRoutes');
...
}

In lib/myapp.routes:

# Routes file for MyApp.pm
ANY / -> Foo.do {
GET /bar -> Foo.bar
ANY /baz -> Foo.baz {
GET /quux -> Foo.quux
}
}
GET /foo/bar/baz/quux -> Foo::Bar::Baz.quux (fbb-quux)

DESCRIPTION

Routes are defined as an HTTP verb, followed by a path, followed by a controller/action pair. (The arrow is optional.) An optional name for the route can be appended with parentheses.

If a route is followed by braces, then it will act as a bridge for the contained routes.

Anything following a "#" is a comment until the end of the line, as in Perl.

CONFIGURATION

$self->plugin('PlainRoutes', {
# Specify the path of the routes file
file => $self->home->rel_file('path/to/myapp.routes'),
# Get automatic names for routes of the form "controller-action"
autoname => 1,
# or do it with a callback
autoname => sub {
my ($verb, $path, $controller, $action) = @_;
return "$controller-$action";
},
});

SUPPORT

Use the issue tracker on the Github repository for bugs/feature requests:

AUTHOR

Cameron Thornton <cthor@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Cameron Thornton.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.