NAME
EntityModel::Web::PSGI - serve EntityModel::Web definitions through PSGI
VERSION
version 0.002
SYNOPSIS
# execute via plackup for example: plackup ./app.psgi
use
EntityModel;
# Load a model which includes a web definition
my
$model
= EntityModel->new->add_plugin(
Web
=> {
})->load_from(
JSON
=> {
file
=>
$ENV
{ENTITYMODEL_JSON_MODEL}
});
# Create the PSGI wrapper
my
$app
= EntityModel::Web::PSGI->new;
# Set up web and template information
my
(
$web
) =
grep
$_
->isa(
'EntityModel::Web'
),
$model
->plugin->list;
my
$tmpl
= EntityModel::Template->new(
include_path
=>
$ENV
{ENTITYMODEL_TEMPLATE_PATH}
);
$tmpl
->process_template(\
qq{[% PROCESS Main.tt2 %]}
);
$app
->template(
$tmpl
);
$app
->web(
$web
);
# Return our PSGI coderef
sub
{
$app
->run_psgi(
@_
) };
DESCRIPTION
Preliminary support for running EntityModel::Web definitions through a PSGI interface.
Expects the "web" EntityModel::Web attribute to be set before any requests are served, with at least one site definition if you want this to do anything useful.
Currently also proxies a "template" attribute, although expect this to be deprecated in a future version (it really shouldn't be here).
METHODS
web
Accessor for the EntityModel::Web definition used for this PSGI instance. Returns $self if used as a mutator:
my
$web
;
$psgi
->web(
$web
)->psgi_request(...);
template
Accessor for the EntityModel::Web definition used for this PSGI instance. Returns $self if used as a mutator:
my
$template
;
warn
$psgi
->template(
$template
)->web;
run_psgi
Process a PSGI request. Will be called by the PSGI framework.
psgi_result
Returns an appropriate PSGI response, either an arrayref or a coderef depending on server support for async/streaming.
SEE ALSO
AUTHOR
Tom Molesworth <cpan@entitymodel.com>
LICENSE
Copyright Tom Molesworth 2011. Licensed under the same terms as Perl itself.