NAME
Plasp::App - Create Plasp Plack App!
SYNOPSIS
In MyApp.pm
In app.psgi
use
MyApp;
$app
= MyApp->new;
DESCRIPTION
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.
CLASS METHODS
- $class->new(%config)
-
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,
);
- $class->config(%config)
-
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'
);
- $class->psgi_app
-
Alternatively, you can just call the
psgi_app
class method, which is the same as calling$class->new
without passing in any configuration.MyApp->config(
ApplicationRoot
=>
'/var/www'
,
DocumentRoot
=>
'root'
,
Global
=>
'lib'
,
GlobalPackage
=>
'MyApp'
,
IncludesDir
=>
'templates'
,
);
$app
= MyApp->psgi_app;