The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::AutoRoute - Mojolicious Plugin to create routes automatically

CAUTION

This is beta release. Implementation will be changed without warnings.

SYNOPSIS

  # Mojolicious
  $self->plugin('AutoRoute');

  # Mojolicious::Lite
  plugin 'AutoRoute';

  # Your route
  $self->puglin('AutoRoute', {route => $self->routes});
  

DESCRIPTION

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.

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);
    });
  }

OPTIONS

route

  route => $route;

You can set parent route if you need. This is Mojolicious::Routes object. Default is $app-routes>.

max_depth

  max_depth => 40;

Template directory max depth. Default is 15.

METHODS

Mojolicious::Plugin::AutoRoute inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

  $plugin->register($app);

Register plugin in Mojolicious application.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.