Marquee Marquee::Plugin::Router - Router

TABLE OF CONTENTS

NAME

Marquee::Plugin::Router - Router

SYNOPSIS

$app->plugin(Router => sub {
    my $r = shift;
    $r->route(qr{^/index\.html})->to(sub {
        my $c = Marquee->c;
        my $req = $c->tx->req;
        my $res = $c->tx->res;
        $res->code(200);
        $res->body('content');
        $res->headers->content_type('text/html');
    });
    
    $r->route(qr{^/special\.html})->to(sub {
        ...
    });
    
    $r->route(qr{^/capture/(.+)-(.+)\.html})->to(sub {
        my ($a, $b) = @_;
        ...
    });
    
    $r->route(qr{^/rare/})->via('get')->to(sub {
        ...
    });
    
    $r->route(qr{^/rare/})->viax('post')->to(sub {
        ...
    });
    
    $r->route(qr{^/default})->to(sub {
        ...
    });
    
    my $bridge = $r->bridge(sub {
        return 1; # or 0
    });
    
    $bridge->route(qr{})->to(sub {...});
});

DESCRIPTION

Marquee::Plugin::Router plugin provides an ability to route requests to certain actions.

ATTRIBUTES

Marquee::Plugin::Router inherits all attributes from Marquee::Plugin and implements the following new ones.

route

Marquee::Plugin::Router::Route instance.

$router->route(Marquee::Plugin::Router::Route->new);
my $r = $router->route;

INSTANCE METHODS

Marquee::Plugin::Router inherits all instance methods from Marquee::Plugin and implements the following new ones.

register

Register the plugin.

$self->register($app, $generator);

SEE ALSO

Marquee::Plugin::Router::Route, Marquee, Mojolicious