Skip Menu |

This queue is for tickets about the Catalyst-Plugin-Static-Simple CPAN distribution.

Report information
The Basics
Id: 57162
Status: resolved
Priority: 0/
Queue: Catalyst-Plugin-Static-Simple

People
Owner: Nobody in particular
Requestors: maja [...] NOSPAMcpanNOSPAM.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.29
Fixed in: 0.29



Subject: new feature: post_run_hook (patch included)
I've added a new features which allows to define a 'post_run_hook' in the config (static => { post_run_hook = 'xyz' } ) which will be called after a static file has been served. I use this to forward to a private method in my Root controller which sets some special response headers for caching. Maybe this is useful for others too, so I applied a patch for v0.29. Thanks - Marc
Subject: Static-Simple.patch
--- /usr/local/lib/perl5/site_perl/5.10.1/Catalyst/Plugin/Static/Simple.pm 2010-05-03 08:11:38.403225099 +0000 +++ Catalyst/Plugin/Static/Simple.pm 2010-05-03 11:52:31.253752367 +0000 @@ -185,6 +185,13 @@ sub _serve_static { if ( defined $fh ) { binmode $fh; $c->res->body( $fh ); + + if ($c->config->{static}{debug} && $c->config->{static}{post_run_hook}) { + + $c->_debug_msg( "-> Running post_run_hook " . $c->config->{static}{post_run_hook} ); + + $c->forward( $c->config->{static}{post_run_hook} ); + } } else { Catalyst::Exception->throw(
Sorry - wrong patch applied. Here is the right one.
Subject: Static-Simple-v2.patch
--- /usr/local/lib/perl5/site_perl/5.10.1/Catalyst/Plugin/Static/Simple.pm 2010-05-03 08:11:38.403225099 +0000 +++ Catalyst/Plugin/Static/Simple.pm 2010-05-03 12:06:08.865376303 +0000 @@ -185,6 +185,13 @@ sub _serve_static { if ( defined $fh ) { binmode $fh; $c->res->body( $fh ); + + if ($c->config->{static}{post_run_hook}) { + + $c->_debug_msg( "-> Running post_run_hook " . $c->config->{static}{post_run_hook} ) if $c->config->{static}{debug}; + + $c->forward( $c->config->{static}{post_run_hook} ); + } } else { Catalyst::Exception->throw(
I don't see how this is any more useful (or less verbose) than just saying: after _serve_static => { shift->forward('my_post_run_hook' }; in your MyApp.pm I don't think it needs a specialist feature in Static::Simple. Please feel free to re-open with a doc patch showing this method however :) Cheers t0m