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

NAME

Mojolicious::Plugin::Sticker - Stick apps together

VERSION

0.0.2

SYNOPSIS

A simple Mojolicious plugin inspired by Mojolicious::Plugin::Mount to join several small mojo apps into a single one.

Differently from Mojolicious::Plugin::Mount you won't provide a prefix. The small apps an their routes are just glued together "as is".

It is like a cat for mojo apps.

    # app foo.pl
    
    use Mojolicious::Lite -signarues;
    
    get '/foo' => sub($c) { $c->render( json => { foo => 123 } ) };
    
    app->start;

    ##################################################

    # app bar.pl
    
    use Mojolicious::Lite -signatures;
    
    get '/bar' => sub($c) { $c->render( json => { bar => 456 } ) };
    
    post '/baz' => sub($c) {
        my $baz  = $c->req->json->{baz} || 0;
    
        $c->render( json => { baz => $baz + 42 } );
    };
    
    app->start;
    
    ##################################################

    # app main.pl
    
    use Mojolicious::Lite;
    
    plugin Sticker => { app => 't/lib/apps/foo' };
    plugin Sticker => { app => 't/lib/apps/bar' };
    
    app->start;

    # main.pl does all that both foo.pl and bar.pl does

DESCRIPTION

Sometimes we have some small apps that we may want to glue together into a bigger one. This is pretty straightforward with Mojolicious.

Mojolicious::Plugin::Mount is a very nice tool to add small apps under a prefix into another app.

This plugin goes down to a slightly different approach. We just glue the apps together keeping its original routes.

This is exclty what this plugin does:

    use Mojolicious::Lite -signtures;

    my $embed = Mojo::Server->new->load_app('my-app');
    app->routes->add_child( $embed->routes );

METHODS

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

register

Mount an aplication and attach its routes as children of main app routes.

SEE ALSO

Mojolicious, Mojolicious::Plugin::Mount, Mojolicious::Guides, https://mojolicious.org.

AUTHOR

Blabos de Blebe, <blabos at cpan.org>