« blib/lib/auto/share/dist/Amon2/flavor/Basic/lib/__PATH__/Web.pm
↑ Summary
blib/lib/auto/share/dist/Amon2/flavor/Large/lib/__PATH__/Web/C/Account.pm »
| 1 | package <% $module %>::Web::Dispatcher; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use utf8; | ||
| 5 | use Amon2::Web::Dispatcher::RouterBoom; | ||
| 6 | |||
| 7 | any '/' => sub { | ||
| 8 | my ($c) = @_; | ||
| 9 | my $counter = $c->session->get('counter') || 0; | ||
| 10 | $counter++; | ||
| 11 | $c->session->set('counter' => $counter); | ||
| 12 | return $c->render('index.tx', { | ||
| 13 | counter => $counter, | ||
| 14 | }); | ||
| 15 | }; | ||
| 16 | |||
| 17 | post '/reset_counter' => sub { | ||
| 18 | my $c = shift; | ||
| 19 | $c->session->remove('counter'); | ||
| 20 | return $c->redirect('/'); | ||
| 21 | }; | ||
| 22 | |||
| 23 | post '/account/logout' => sub { | ||
| 24 | my ($c) = @_; | ||
| 25 | $c->session->expire(); | ||
| 26 | return $c->redirect('/'); | ||
| 27 | }; | ||
| 28 | |||
| 29 | 1; |