File Coverage

blib/lib/Web/Request/Types.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             package Web::Request::Types;
2             BEGIN {
3 23     23   800 $Web::Request::Types::AUTHORITY = 'cpan:DOY';
4             }
5             {
6             $Web::Request::Types::VERSION = '0.11';
7             }
8 23     23   121 use strict;
  23         46  
  23         428  
9 23     23   99 use warnings;
  23         46  
  23         566  
10              
11 23     23   126 use Moose::Util::TypeConstraints;
  23         102  
  23         246  
12              
13             class_type('HTTP::Headers');
14              
15             subtype 'Web::Request::Types::StringLike',
16             as 'Object',
17             where {
18             return unless overload::Method($_, '""');
19             my $tc = find_type_constraint('Web::Request::Types::PSGIBodyObject');
20             return !$tc->check($_);
21             };
22              
23             duck_type 'Web::Request::Types::PSGIBodyObject' => ['getline', 'close'];
24              
25             subtype 'Web::Request::Types::PSGIBody',
26             as 'ArrayRef[Str|Web::Request::Types::StringLike]|FileHandle|Web::Request::Types::PSGIBodyObject';
27              
28             subtype 'Web::Request::Types::HTTPStatus',
29             as 'Int',
30             where { /^[1-5][0-9][0-9]$/ };
31              
32             subtype 'Web::Request::Types::HTTP::Headers',
33             as 'HTTP::Headers';
34             coerce 'Web::Request::Types::HTTP::Headers',
35             from 'ArrayRef',
36             via { HTTP::Headers->new(@$_) },
37             from 'HashRef',
38             via { HTTP::Headers->new(%$_) };
39              
40             coerce 'Web::Request::Types::PSGIBody',
41             from 'Str|Web::Request::Types::StringLike',
42             via { [ $_ ] };
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =head1 NAME
51              
52             Web::Request::Types
53              
54             =head1 VERSION
55              
56             version 0.11
57              
58             =head1 AUTHOR
59              
60             Jesse Luehrs <doy@tozt.net>
61              
62             =head1 COPYRIGHT AND LICENSE
63              
64             This software is copyright (c) 2013 by Jesse Luehrs.
65              
66             This is free software; you can redistribute it and/or modify it under
67             the same terms as the Perl 5 programming language system itself.
68              
69             =cut