
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 0.91 KB | hits: 10 | expires: Never
#!/usr/bin/perl
use lib qw(lib);
use HTML::Mason::PSGIHandler;
use Plack::Builder;
use Plack::Session::Store::Cache;
use Cache::Memcached;
use DBIx::Connector;
my $h = HTML::Mason::PSGIHandler->new(
comp_root => '/home/nic/survey_app',
allow_globals => [ '$u', '$dbh' ],
);
my $dbc = DBIx::Connector->new( 'dbi:Pg:dbname=surveys', 'surveys', 'PASSWORD', {
RaiseError => 1, AutoCommit => 1, pg_enable_utf8 => 1
} );
{
package HTML::Mason::Commands;
use Data::Dumper;
}
my $handler = sub {
my $env = shift;
$env->{dbh} = $dbc->dbh;
$h->handle_psgi($env);
};
builder {
enable 'AddDefaultCharset', charset => 'utf-8';
enable 'Static', path => qr{^/art/};
enable 'Static', path => qr{^/favicon.ico};
enable 'Rewrite', rules => sub { s{/$}{/index}; return undef; };
enable 'Session', store => Plack::Session::Store::Cache->new(
cache => Cache::Memcached->new( servers => [ 'localhost:11211' ] )
);
$handler;
}