Created
December 5, 2017 16:03
-
-
Save jberger/b0999dacc596edb715b8d62adda82614 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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