Mojolicious::Plugin::AutoRoute - Mojolicious Plugin to create routes automatically
This is beta release. Implementation will be changed without warnings.
# Mojolicious $self->plugin('AutoRoute'); # Mojolicious::Lite plugin 'AutoRoute'; # Your route $self->puglin('AutoRoute', {route => $self->routes});
Mojolicious::Plugin::AutoRoute is a Mojolicious plugin to create routes automatically.
Routes corresponding to URL is created .
TEMPLATES ROUTES templates/index.html.ep # / /foo.html.ep # /foo /foo/bar.html.ep # /foo/bar /foo/bar/baz.html.ep # /foo/bar/baz
If you like PHP, this plugin is very good.
PHP
By default, Mojolicious template is cached. If you want not to cache template, you clear cache before dispaching.
# Mojolicious::Lite use Mojo::Cache; app->hook(before_dispatch => sub { my $c = shift; # Clear cache $c->app->renderer->cache(Mojo::Cache->new); }); # Mojolicious use Mojo::Cache; sub startup { my $self = shift; $self->hook(before_dispatch => sub { my $c = shift; # Clear cache $c->app->renderer->cache(Mojo::Cache->new); }); }
route
route => $route;
You can set parent route if you need. This is Mojolicious::Routes object. Default is $app-routes>.
$app-
max_depth
max_depth => 40;
Template directory max depth. Default is 15.
15
Mojolicious::Plugin::AutoRoute inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register($app);
Register plugin in Mojolicious application.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
To install Mojolicious::Plugin::AutoRoute, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::AutoRoute
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::AutoRoute
For more information on module installation, please visit the detailed CPAN module installation guide.