Hi all, I'm pretty new to Dancer and I'm trying to put together a quick demo with Plack::Builder and multiple apps. I've created 2 apps in separate directories - app1 and app2, and in a directory above I've got app.psgi with the following code: use Dancer2 ':syntax'; use Plack::Builder; use lib '/home/mj/app1/lib'; use lib '/home/mj/app2/lib'; use app1; use app2; setting apphandler => 'PSGI'; my $app1 = sub { my $env = shift; local $ENV{DANCER_APPDIR} = '/home/mj/app1'; load_app "app1"; Dancer2::App->set_running_app('app1'); setting appdir => '/home/mj/app1'; Dancer2::Config->load; my $request = Dancer2::Request->new( env => $env ); Dancer2->dance($request); }; my $app2 = sub { my $env = shift; local $ENV{DANCER_APPDIR} = '/home/mj/app2'; load_app "app2"; Dancer2::App->set_running_app('app2'); setting appdir => '/home/mj/app2'; Dancer2::Config->load; my $request = Dancer2::Request->new( env => $env ); Dancer2->dance($request); }; builder { mount "/app1" => builder {$app1}; mount "/app2" => builder {$app2}; }; Following the tutorial here: http://search.cpan.org/~sukria/Dancer2-0.05/lib/Dancer2/Deployment.pod#Runni.... I keep getting this error: String found where operator expected at /home/mj/app.psgi line 16, near "load_app "app1"" (Do you need to predeclare load_app?) It's probably something really simple but can anyone see what's wrong? Cheers
Hi Mark, On 11/02/2015 8:57 pm, mark jones wrote:
Following the tutorial here: http://search.cpan.org/~sukria/Dancer2-0.05/lib/Dancer2/Deployment.pod#Runni....
That tutorial link you provided is to a (very) old version of Dancer2. I strongly recommend using the latest release (v0.158000) if you need multiple apps [1]. Your app.psgi then becomes use Plack::Builder; use lib '/home/mj/app1/lib'; use lib '/home/mj/app2/lib'; use app1; use app2; builder { mount "/app1" => app1->psgi_app; mount "/app2" => app2->psgi_app; }; Hope that helps, Russell. [1] well, at least Dancer2 v0.151000 for this example to work.
Thanks Russell, My bad!! I knew I'd be doing something silly. Now to convince my boss that we need to use Dancer. MJ
On 11 Feb 2015, at 11:55, Russell Jenkins <russell.jenkins@strategicdata.com.au> wrote:
Hi Mark,
On 11/02/2015 8:57 pm, mark jones wrote:
Following the tutorial here: http://search.cpan.org/~sukria/Dancer2-0.05/lib/Dancer2/Deployment.pod#Runni....
That tutorial link you provided is to a (very) old version of Dancer2.
I strongly recommend using the latest release (v0.158000) if you need multiple apps [1]. Your app.psgi then becomes
use Plack::Builder; use lib '/home/mj/app1/lib'; use lib '/home/mj/app2/lib';
use app1; use app2;
builder { mount "/app1" => app1->psgi_app; mount "/app2" => app2->psgi_app; };
Hope that helps, Russell.
[1] well, at least Dancer2 v0.151000 for this example to work.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (2)
-
mark jones -
Russell Jenkins