Created
January 28, 2011 12:39
-
-
Save harshals/800202 to your computer and use it in GitHub Desktop.
Hosting Multiple Dancer Apps using Plack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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