Catalyst::Plugin::RunAfterRequest

Run code after the response has been sent
Download

Catalyst::Plugin::RunAfterRequest Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Florian Ragwitz
  • Publisher web site:
  • http://search.cpan.org/~flora/

Catalyst::Plugin::RunAfterRequest Tags


Catalyst::Plugin::RunAfterRequest Description

Run code after the response has been sent Sometimes you want to run something after you've sent the reponse back to the client. For example you might want to send a tweet to Twitter, or do some logging, or something that will take a long time and would delay the response.Catalyst::Plugin::RunAfterRequest is a Perl module that provides a convenient way to do that by simply calling run_after_request and adding a closure to it.SYNOPSIS #### In MyApp.pm use Catalyst qw(RunAfterRequest); #### In your controller sub my_action : Local { my ( $self, $c ) = @_; # do your normal processing... # add code that runs after response has been sent to client $c->run_after_request( # sub { $self->do_something_slow(); }, sub { $self->do_something_else_as_well(); } ); # continue handling the request } #### Or in your Model: package MyApp::Model::Foo; use Moose; extends 'Catalyst::Model'; with 'Catalyst::Model::Role::RunAfterRequest'; sub some_method { my $self = shift; $self->_run_after_request( sub { $self->do_something_slow(); }, sub { $self->do_something_else_as_well(); } ); } Requirements: · Perl


Catalyst::Plugin::RunAfterRequest Related Software