File Coverage

blib/lib/Metabrik/Server/Http.pm
Criterion Covered Total %
statement 9 18 50.0
branch n/a
condition 0 11 0.0
subroutine 3 5 60.0
pod 1 2 50.0
total 13 36 36.1


line stmt bran cond sub pod time code
1             #
2             # $Id$
3             #
4             # server::http Brik
5             #
6             package Metabrik::Server::Http;
7 1     1   614 use strict;
  1         2  
  1         28  
8 1     1   5 use warnings;
  1         2  
  1         26  
9              
10 1     1   5 use base qw(Metabrik);
  1         2  
  1         279  
11              
12             sub brik_properties {
13             return {
14 0     0 1   revision => '$Revision$',
15             tags => [ qw(unstable) ],
16             author => 'GomoR ',
17             license => 'http://opensource.org/licenses/BSD-3-Clause',
18             attributes => {
19             datadir => [ qw(datadir) ],
20             hostname => [ qw(listen_hostname) ],
21             port => [ qw(listen_port) ],
22             _http => [ qw(INTERNAL) ],
23             },
24             attributes_default => {
25             hostname => 'localhost',
26             port => 8888,
27             },
28             commands => {
29             start => [ qw(listen_hostname|OPTIONAL listen_port|OPTIONAL datadir|OPTIONAL) ],
30             },
31             require_modules => {
32             'HTTP::Server::Brick' => [ ],
33             },
34             };
35             }
36              
37             sub start {
38 0     0 0   my $self = shift;
39 0           my ($hostname, $port, $root) = @_;
40              
41 0   0       $hostname ||= $self->hostname;
42 0   0       $port ||= $self->port;
43 0   0       $root ||= $self->datadir;
44              
45 0   0       my $http = HTTP::Server::Brick->new(
46             port => $port,
47             host => $hostname,
48             timeout => defined($self->global) && $self->global->rtimeout || 3,
49             );
50              
51 0           $http->mount('/' => { path => $root });
52              
53 0           return $self->_http($http)->start;
54             }
55              
56             1;
57              
58             __END__