HTTPServer/TemplateHandler.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 2 SCAR 11.0
CC
2
Cov
0%
handle_plainfile
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 package POE::Component::Server::HTTPServer::TemplateHandler;
2 use strict;
3 use HTTP::Status;
4 use HTML::Template;
5 use HTML::Template::HashWrapper;
6 use POE::Component::Server::HTTPServer::Handler;
7 use base 'POE::Component::Server::HTTPServer::StaticHandler';
8  
9 sub handle_plainfile {
10 my $self = shift;
11 my $filepath = shift;
12 my $context = shift;
13  
14 unless ( -f $filepath && -r _ ) {
15 $context->{error_message} = "No such resource";
16 return H_CONT;
17 }
18  
19 my $ctx_assn = HTML::Template::HashWrapper->new($context);
20 my $templ =
21 HTML::Template->new( filename => $filepath,
22 die_on_bad_params => 0,
23 # cache => 1,
24 associate => $ctx_assn,
25 global_vars => 0,
26 );
27 $context->{response}->code( RC_OK );
28 $context->{response}->content( $templ->output );
29 return H_FINAL;
30 }
31  
32 1;
33 __END__