I have an app that may choose to serve a file from disk - or go to Catalyst and generate a dynamic one.
Something like this (inside call()):
if (-f $path){
my $app = Plack::App::File->new(file => $path)->to_app; #serve published page
$res = $app->($env);
}else{
log_debug "Fall through to app ";
$res = $self->app->($env);.
}
I'd like to set some cookies when it gets back. So I use Plack::Util
Plack::Util::response_cb($res, sub {
my $res = shift;
log_debug "Handling app response";
...
});
The results? In the first case (Plack::App::File), everything works as expected. In the second (continue to the app the normal way) it never comes back in.
I wonder why this is happenning? Here is my psgi initialization:
my $app = MainApp->psgi_app(@_);
$app = Plack::MyAppAbove->wrap($app);
$app = MainApp->apply_default_middlewares($app);