Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 0.91 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2.  
  3. use lib qw(lib);
  4.  
  5. use HTML::Mason::PSGIHandler;
  6. use Plack::Builder;
  7. use Plack::Session::Store::Cache;
  8. use Cache::Memcached;
  9. use DBIx::Connector;
  10.  
  11. my $h = HTML::Mason::PSGIHandler->new(
  12.         comp_root => '/home/nic/survey_app',
  13.         allow_globals => [ '$u', '$dbh' ],
  14. );
  15.  
  16. my $dbc = DBIx::Connector->new( 'dbi:Pg:dbname=surveys', 'surveys', 'PASSWORD', {
  17.         RaiseError => 1, AutoCommit => 1, pg_enable_utf8 => 1
  18. } );
  19.  
  20. {
  21.  
  22.         package HTML::Mason::Commands;
  23.  
  24.         use Data::Dumper;
  25.  
  26. }
  27.  
  28. my $handler = sub {
  29.         my $env = shift;
  30.  
  31.         $env->{dbh} = $dbc->dbh;
  32.         $h->handle_psgi($env);
  33. };
  34.  
  35. builder {
  36.         enable 'AddDefaultCharset', charset => 'utf-8';
  37.         enable 'Static', path => qr{^/art/};
  38.         enable 'Static', path => qr{^/favicon.ico};
  39.         enable 'Rewrite', rules => sub { s{/$}{/index}; return undef; };
  40.         enable 'Session', store => Plack::Session::Store::Cache->new(
  41.                 cache => Cache::Memcached->new( servers => [ 'localhost:11211' ] )
  42.         );
  43.         $handler;
  44. }