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

NAME

MojoX::Dispatcher::Routes - Routes Dispatcher

SYNOPSIS

    use MojoX::Dispatcher::Routes;

    # New dispatcher
    my $dispatcher = MojoX::Dispatcher::Routes->new;

    # Dispatch
    $dispatcher->dispatch(MojoX::Dispatcher::Routes::Controller->new);

DESCRIPTION

MojoX::Dispatcher::Routes is a MojoX::Routes based dispatcher.

ATTRIBUTES

MojoX::Dispatcher::Routes inherits all attributes from MojoX::Routes and implements the following ones.

controller_base_class

    my $base    = $dispatcher->controller_base_class;
    $dispatcher = $dispatcher->controller_base_class(
        'MojoX::Dispatcher::Routes::Controller'
    );

Base class used to identify controllers, defaults to MojoX::Dispatcher::Routes::Controller.

hidden

    my $hidden  = $dispatcher->hidden;
    $dispatcher = $dispatcher->hidden(
        [qw/new attr tx render req res stash/]
    );

Methods and attributes that are hidden from the dispatcher.

namespace

    my $namespace = $dispatcher->namespace;
    $dispatcher   = $dispatcher->namespace('Foo::Bar::Controller');

Namespace to search for controllers.

METHODS

MojoX::Dispatcher::Routes inherits all methods from MojoX::Routes and implements the following ones.

auto_render

    $dispatcher->auto_render(MojoX::Dispatcher::Routes::Controller->new);

Automatic rendering.

detour

    $dispatcher = $dispatcher->detour(action => 'foo');
    $dispatcher = $dispatcher->detour({action => 'foo'});
    $dispatcher = $dispatcher->detour('controller#action');
    $dispatcher = $dispatcher->detour('controller#action', foo => 'bar');
    $dispatcher = $dispatcher->detour('controller#action', {foo => 'bar'});
    $dispatcher = $dispatcher->detour($app);
    $dispatcher = $dispatcher->detour($app, foo => 'bar');
    $dispatcher = $dispatcher->detour($app, {foo => 'bar'});
    $dispatcher = $dispatcher->detour('MyApp');
    $dispatcher = $dispatcher->detour('MyApp', foo => 'bar');
    $dispatcher = $dispatcher->detour('MyApp', {foo => 'bar'});

Set default parameters for this route and allow partial matching to simplify application embedding. Note that this method is EXPERIMENTAL and might change without warning!

dispatch

    my $e = $dispatcher->dispatch(
        MojoX::Dispatcher::Routes::Controller->new
    );

Match routes and dispatch.

hide

    $dispatcher = $dispatcher->hide('new');

Hide method or attribute from the dispatcher.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicious.org.