Catalyst-Plugin-ServeFile

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/ServeFile.pm  view on Meta::CPAN


  my $file_proto = File::Spec->catdir(
    File::Spec->no_upwards(
      map { File::Spec->splitdir($_) } @_ ));

  my $full_path = File::Spec->catfile($root, $file_proto);
  my $content_type = Plack::MIME->mime_type($full_path) || 'application/octet';

  if(my $allowed_content_types = $settings{allowed_content_types}) {
    unless(scalar( grep { lc($content_type) eq lc($_) } @$allowed_content_types)) {
      $c->log->debug("Static file has disallowed content-type of '$content_type'") if $c->debug;
      return;
    }
  }

  my ($fh, @stat) = $c->$get_asset_from_filesystem($full_path);
  return unless $fh;

  if ($content_type =~ m!^text/!) {
    my $encoding =  $settings{encoding} || "utf-8";
    $content_type .= "; charset=$encoding";



( run in 1.666 second using v1.01-cache-2.11-cpan-524268b4103 )