EntityModel::Web::PSGI - serve EntityModel::Web definitions through PSGI
version 0.002
# execute via plackup for example: plackup ./app.psgi use EntityModel; use EntityModel::Web::PSGI; # 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(@_) };
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).
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(...);
my $template; warn $psgi->template($template)->web;
Process a PSGI request. Will be called by the PSGI framework.
Returns an appropriate PSGI response, either an arrayref or a coderef depending on server support for async/streaming.
PSGI
EntityModel
EntityModel::Web
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011. Licensed under the same terms as Perl itself.
To install EntityModel::Web::PSGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm EntityModel::Web::PSGI
CPAN shell
perl -MCPAN -e shell install EntityModel::Web::PSGI
For more information on module installation, please visit the detailed CPAN module installation guide.