use MIME::Types;
use NEXT;
-if ( Catalyst->VERSION le '5.33' ) {
- require File::Slurp;
-}
-
our $VERSION = '0.11';
__PACKAGE__->mk_classdata( qw/_static_mime_types/ );
__PACKAGE__->mk_accessors( qw/_static_file
_static_debug_message/ );
-# prepare_action is used to first check if the request path is a static file.
-# If so, we skip all other prepare_action steps to improve performance.
sub prepare_action {
my $c = shift;
my $path = $c->req->path;
return $c->NEXT::ACTUAL::prepare_action(@_);
}
-# dispatch takes the file found during prepare_action and serves it
sub dispatch {
my $c = shift;
}
}
-# finalize serves up final header information
sub finalize {
my $c = shift;
$c->NEXT::setup(@_);
+ if ( Catalyst->VERSION le '5.33' ) {
+ require File::Slurp;
+ }
+
$c->config->{static}->{dirs} ||= [];
$c->config->{static}->{include_path} ||= [ $c->config->{root} ];
$c->config->{static}->{mime_types} ||= {};
$c->config->{static}->{debug} ||= $c->debug;
if ( ! defined $c->config->{static}->{no_logs} ) {
$c->config->{static}->{no_logs} = 1;
- }
+ }
# load up a MIME::Types object, only loading types with
# at least 1 file extension
# new method, pass an IO::File object to body
my $fh = IO::File->new( $full_path, 'r' );
if ( defined $fh ) {
- $fh->binmode;
+ binmode $fh;
$c->res->body( $fh );
}
else {
SetHandler default-handler
</Location>
+=head1 INTERNAL EXTENDED METHODS
+
+Static::Simple extends the following steps in the Catalyst process.
+
+=head2 prepare_action
+
+prepare_action is used to first check if the request path is a static file.
+If so, we skip all other prepare_action steps to improve performance.
+
+=head2 dispatch
+
+dispatch takes the file found during prepare_action and writes it to the
+output.
+
+=head2 finalize
+
+finalize serves up final header information and displays any log messages.
+
+=head2 setup
+
+setup initializes all default values.
+
=head1 SEE ALSO
L<Catalyst>, L<Catalyst::Plugin::Static>,