Mojolicious::Plugin::AdvancedMod::ActionFilter - Analogue of Rails: before_filter, after_filter
$self->action_filter( filter_name => sub { ... } );
# Main app file sub startup { my $self = shift; ... $self->action_filter( is_auth => sub { shift->render( text => "is_auth filter" ) }, test => sub { shift->render( text => "test before_filter" ); }, ); } # Controller our $BEFORE_FILTERS = { is_auth => [qw/show/] }; our $AFTER_FILTERS = { test => [qw/show/] }; sub show { my ( $self, $filter, $action ) = @_; $self->render( text => 'show action' ); } sub index { my $self = shift; $self->render( text => 'index action' ); } # Log [info] Applying before_filter is_auth for example#show [info] Applying after_filter test for example#show [debug] GET "/show".
Grishkovelli grishkovelli@gmail.com
https://github.com/grishkovelli/Mojolicious-Plugin-AdvancedMod
Copyright (C) 2013, 2014 Grishkovelli grishkovelli@gmail.com
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Mojolicious::Plugin::AdvancedMod, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::AdvancedMod
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::AdvancedMod
For more information on module installation, please visit the detailed CPAN module installation guide.