Plasp::App - Create Plasp Plack App!
In MyApp.pm
MyApp.pm
package MyApp; use Moo; with 'Plasp::App'; around new => sub { my ( $orig, $class ) = ( shift, shift ); $class->$orig( @_ ); }; 1;
In app.psgi
app.psgi
use MyApp; $app = MyApp->new;
Use Plasp::App as a Role::Tiny to create a new PSGI app. Call the new class method and get a subroutine in return which will serve a PSGI application.
new
You can pass in the configuration in new
$app = MyApp->new( ApplicationRoot => '/var/www', DocumentRoot => 'root', Global => 'lib', GlobalPackage => 'MyApp', IncludesDir => 'templates', MailHost => 'localhost', MailFrom => 'myapp@localhost', XMLSubsMatch => '(?:myapp):\w+', Error404Path => '/error404.asp', Error500Path => '/error500.asp', Debug => 0, );
You can even set or override the configuration in another context either before or after initialization;
$app = MyApp->new; MyApp->config(ApplicationRoot => '/var/www'); MyApp->config(DocumentRoot => 'html'); MyApp->config(Global => 'lib'); MyApp->config(GlobalPackage => 'MyApp'); MyApp->config(IncludesDir => 'templates');
Alternatively, you can just call the psgi_app class method, which is the same as calling $class->new without passing in any configuration.
psgi_app
$class->new
MyApp->config( ApplicationRoot => '/var/www', DocumentRoot => 'root', Global => 'lib', GlobalPackage => 'MyApp', IncludesDir => 'templates', ); $app = MyApp->psgi_app;
Plasp
To install Plasp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plasp
CPAN shell
perl -MCPAN -e shell install Plasp
For more information on module installation, please visit the detailed CPAN module installation guide.