blib/lib/HTTP/Server/Simple/Kwiki.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 49 CC 3 SCAR 16.1
CC
3
Cov
0%
handle_request
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.0
1 package HTTP::Server::Simple::Kwiki;
2  
3 use HTTP::Server::Simple::CGI;
4 use HTTP::Server::Simple::Static;
5 use IO::Capture::Stdout;
6 use base qw(HTTP::Server::Simple::CGI HTTP::Server::Simple::Static);
7 use strict;
8 use warnings;
9 use Kwiki;
10 our $VERSION = 0.29;
11  
12 sub handle_request {
13 my($self, $cgi) = @_;
14  
15 my $url = "http://localhost" . $ENV{REQUEST_URI};
16  
17 if ($url =~ /\.(gif|png|css)/) {
18 $self->serve_static($cgi, ".");
19 } else {
20 my $capture = IO::Capture::Stdout->new();
21 $capture->start();
22 Kwiki->new->debug->process('config*.*', -plugins => 'plugins');
23 $capture->stop();
24 my $output = join '', $capture->read;
25  
26 if ($output =~ m{302}) {
27 $output = "HTTP/1.0 302 OK\n$output";
28 } else {
29 $output = "HTTP/1.0 200 OK\n$output";
30 }
31  
32 print $output;
33 }
34 }
35  
36 1;
37  
38 __END__