Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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:

  • Reloading the entire Raisin::API module under a different namespace for each app (breaks helper methods in Raisin, so I'd have to rename all modules and code - way too messy)
  • Attempting to overload the "my" variables via an extra 'package Raisin::API' block (didn't think it would work, but worth a try - it didn't).

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?


In reply to Running multiple Raisin apps on a single Plack server by cLive ;-)

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2022-09-27 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (118 votes). Check out past polls.

    Notices?