Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jberger
Created December 5, 2017 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/b0999dacc596edb715b8d62adda82614 to your computer and use it in GitHub Desktop.
Save jberger/b0999dacc596edb715b8d62adda82614 to your computer and use it in GitHub Desktop.
package Local::EmbeddedApp;
use Mojolicious::Lite;
get '/hello' => {text => 'hello from embedded app'};
my $embedded = app;
package Local::HostApp;
use Mojolicious::Lite;
app->routes->route('/embedded')->detour(app => $embedded);
get '/hello' => {text => 'hello from host app'};
get '/:placeholder/firm' => {text => 'placholder'};
my $host = app;
package main;
use Test::More;
use Test::Mojo;
my $t = Test::Mojo->new->app($host);
$t->get_ok('/hello')
->status_is(200)
->content_like(qr/host/);
$t->get_ok('/embedded/hello')
->status_is(200)
->content_like(qr/embedded/);
$t->get_ok('/other/firm');
warn Mojo::Util::dumper [keys %{ $host->routes->cache->{cache} }];
warn Mojo::Util::dumper [keys %{ $embedded->routes->cache->{cache} }];
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment