[dancer-users] Dancer2 -- multiple apps with different config(.yml) in one process

Clive Eisen clive at hildebrand.co.uk
Sun May 27 19:00:24 BST 2018


I had this issue (more or less)

You can set the cookie name in the before hook

engine('session')->{cookie_name} = ‘my.dancer.cookie’;

— 
Clive Eisen
GPG: 3818B5F1






> On 27 May 2018, at 18:33, Erik Huelsmann <ehuels at gmail.com> wrote:
> 
> Hi,
> 
> Over at the LedgerSMB project (https://ledgersmb.org/ <https://ledgersmb.org/>), we moved a lot of our old CGI code to PSGI over the last year. Recently, I've factored out many "infrastructure" level items into Plack middleware.
> 
> We've wanted to move to Dancer as our web framework for years. And this weekend I made a first stab at such a move. As a result I have some questions (but more may come). Some questions were immediately answered by Stephan Hornburg in our chat channel (thanks Stephan!) but the most important one remains open.
> 
> Question: Dancer2's documentation points out that we can use 2 applications hosted on 1 PSGI server. The relevant section is: http://search.cpan.org/~cromedome/Dancer2-0.205002/lib/Dancer2/Manual.pod#Running_multiple_apps_with_Plack::Builder <http://search.cpan.org/~cromedome/Dancer2-0.205002/lib/Dancer2/Manual.pod#Running_multiple_apps_with_Plack::Builder>
> And while that works, both of these applications resolve their configuration to one and the same "config.yml". This is where my problem is: while I don't mind (would like to, even) share 99% of the configuration between two applications I want to mount, the two applications I want to mount, need separate authentication cookies. As far as I'm aware, I'd need to resolve to two different "config.yml" files (in my case I'd prefer "main_config.yml" and "setup_config.yml").
> 
> A bit of background to my question: LedgerSMB is an ERP application which consists of two logically separate applications: 'main' and 'setup'. "main" is the application for regular users while "setup" is for application/functional maintenance (application admin). Since many businesses have a "superuser" appointed as their admin, this user has 2 roles. He may want to log into both applications at the same time, each in a separate window on the same browser. In order to be able to do that, I need to be able to set the session cookie for both applications to be different from each other. It's my understanding that the "best" way to set cookie names through the configuration. Hence my question how to get two applications pointing to two different configuration files.
> 
> I've tried multiple approaches so far without success:
> 1. "use Dancer2 config_location => 'path/to/config';"
> 2. read the sources of Dancer2 for a couple of hours
> 3. Ask racke
> 
> 
> Could you please advise? Thanks in advance!
> 
> 
> -- 
> Bye,
> 
> Erik.
> 
> http://efficito.com <http://efficito.com/> -- Hosted accounting and ERP.
> Robust and Flexible. No vendor lock-in.
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20180527/8faad7b6/attachment.html>


More information about the dancer-users mailing list