http://qs1969.pair.com?node_id=11140903

cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

I'm loving Raisin as a framework for OpenAPI applications, but I've hit a wall and am needing some fresh eyes.

I want to spin up multiple Raisin apps on the same Plack server, something like this:

use Plack::Builder; use RaisinApp1; use RaisinApp2; builder { mount '/app1' => RaisinApp1->new(); mount '/app2' => RaisinApp2->new(); };

But, since Raisin is a functional framework, there's just a single application created, with the second "app" just being concatenated to the first, and with imported methods failing (eg, plugin) because they get imported into the first namespace that uses them.

I'm playing around with possible solutions, but nothing has stuck so far:

What I *think* I need is a way to load Raisin::API and it's dependencies in a scope limited way to lock it to each app's instance, but I can't think of how to do it. Would that be doable, or should I just drop the idea of trying to run multiple Raisin apps under Plack in this way? (yes, this is an odd setup, but it's transitional for a year or two while migrating away from a monolith)

Something like this:

my $app1 = some_scope_wrapper(sub { use Raisin::API; build_app1_here(); }); my $app2 = some_scope_wrapper(sub { use Raisin::API; build_app2_here(); }); # Raisin code won't work here...

Am I barking up the wrong tree, or just barking mad?

Replies are listed 'Best First'.
Re: Running multiple Raisin apps on a single Plack server
by Anonymous Monk on Jan 29, 2022 at 10:43 UTC
Re: Running multiple Raisin apps on a single Plack server
by etj (Deacon) on Jan 28, 2022 at 21:40 UTC
    That's not necessarily an "or" question ;-)