« blib/lib/auto/share/dist/Amon2/flavor/Large/lib/__PATH__/Web/C/Account.pm
↑ Summary
blib/lib/auto/share/dist/Amon2/flavor/Large/lib/__PATH__/__MONIKER__/C/Root.pm »
| 1 | package <% $module %>::<% $moniker %>; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use utf8; | ||
| 5 | use parent qw(<% $module %> Amon2::Web); | ||
| 6 | use File::Spec; | ||
| 7 | |||
| 8 | # dispatcher | ||
| 9 | use <% $module %>::<% $moniker %>::Dispatcher; | ||
| 10 | sub dispatch { | ||
| 11 | return (<% $module %>::<% $moniker %>::Dispatcher->dispatch($_[0]) or die "response is not generated"); | ||
| 12 | } | ||
| 13 | |||
| 14 | # setup view | ||
| 15 | use <% $module %>::<% $moniker %>::View; | ||
| 16 | { | ||
| 17 | sub create_view { | ||
| 18 | my $view = <% $module %>::<% $moniker %>::View->make_instance(__PACKAGE__); | ||
| 19 | no warnings 'redefine'; | ||
| 20 | *<% $module %>::<% $moniker %>::create_view = sub { $view }; # Class cache. | ||
| 21 | $view | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | # load plugins | ||
| 26 | __PACKAGE__->load_plugins( | ||
| 27 | 'Web::FillInFormLite', | ||
| 28 | '+<% $module %>::<% $moniker %>::Plugin::Session', | ||
| 29 | ); | ||
| 30 | |||
| 31 | sub show_error { | ||
| 32 | my ( $c, $msg, $code ) = @_; | ||
| 33 | my $res = $c->render( 'error.tx', { message => $msg } ); | ||
| 34 | $res->code( $code || 500 ); | ||
| 35 | return $res; | ||
| 36 | } | ||
| 37 | |||
| 38 | # for your security | ||
| 39 | __PACKAGE__->add_trigger( | ||
| 40 | AFTER_DISPATCH => sub { | ||
| 41 | my ( $c, $res ) = @_; | ||
| 42 | |||
| 43 | # http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx | ||
| 44 | $res->header( 'X-Content-Type-Options' => 'nosniff' ); | ||
| 45 | |||
| 46 | # http://blog.mozilla.com/security/2010/09/08/x-frame-options/ | ||
| 47 | $res->header( 'X-Frame-Options' => 'DENY' ); | ||
| 48 | |||
| 49 | # Cache control. | ||
| 50 | $res->header( 'Cache-Control' => 'private' ); | ||
| 51 | }, | ||
| 52 | ); | ||
| 53 | |||
| 54 | 1; |