Skip to content

Instantly share code, notes, and snippets.

@harshals
Created January 28, 2011 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshals/800202 to your computer and use it in GitHub Desktop.
Save harshals/800202 to your computer and use it in GitHub Desktop.
Hosting Multiple Dancer Apps using Plack
## Main app.psgi
use App1;
use App2;
use Plack::Builder;
use Plack::App::URLMap;
my $app1 = sub {
my $env = shift;
my $request = Dancer::Request->new( $env );
App1->dance( $request );
};
my $app2 = sub {
my $env = shift;
my $request = Dancer::Request->new( $env );
App2->dance( $request );
};
builder {
mount "/a1" => builder { $app1; };
## c1.myapp.com
mount "/a2" => builder { $app2; };
## c2.myapp.com
};
package App1;
use strict;
use warnings;
use Dancer ':syntax';
set 'apphandler' => "PSGI";
get '/' => sub {
return "Hello from App1";
};
get '/app1' => sub {
return "Route app1 called from App1";
};
get '/app2' => sub {
return "Route app2 called from App1";
};
1;
package App2;
use strict;
use warnings;
use Dancer ':syntax';
set 'apphandler' => "PSGI";
get '/' => sub {
return "Hello from App2";
};
get '/app1' => sub {
return "Route app1 called from App2";
};
get '/app2' => sub {
return "Route app2 called from App2";
};
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment