Types/PSGIServer.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran n/a Conditioncond 0.0% 0 / 18 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 77 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package POEx::Types::PSGIServer;
2 BEGIN {
3 $POEx::Types::PSGIServer::VERSION = '1.110670';
4 }
5  
6 #ABSTRACT: Provides type constraints for use in POEx::Role::PSGIServer
7 use warnings;
8 use strict;
9  
10 use MooseX::Types -declare => [qw/
11 PSGIServerContext
12 PSGIResponse
13 PSGIBody
14 HTTPRequest
15 HTTPCode
16 /];
17  
18 use MooseX::Types::Moose(':all');
19 use MooseX::Types::Structured(':all');
20 use POEx::Types(':all');
21 use HTTP::Request;
22 use HTTP::Status;
23 use Plack::Util;
24 use Scalar::Util;
25  
26  
27 subtype PSGIServerContext,
28 as Dict [
29 request => HTTPRequest,
30 wheel => Optional[Wheel],
31 version => Str,
32 protocol => Str,
33 connection => Str,
34 keep_alive => Bool,
35 chunked => Optional[Maybe[Bool]],
36 explicit_length => Optional[Maybe[Bool]],
37 ];
38  
39  
40 subtype HTTPRequest,
41 as class_type('HTTP::Request');
42  
43  
44 subtype HTTPCode,
45 as Int,
46 where {
47 HTTP::Status::is_info($_)
48 || HTTP::Status::is_success($_)
49 || HTTP::Status::is_redirect($_)
50 || HTTP::Status::is_error($_)
51 };
52  
53  
54 subtype PSGIBody,
55 as Ref,
56 where {
57 Plack::Util::is_real_fh($_)
58 || (Scalar::Util::blessed($_) && ($_->can('getline') && $_->can('close')))
59 };
60  
61  
62 subtype PSGIResponse,
63 as Tuple [
64 HTTPCode,
65 ArrayRef,
66 Optional[ArrayRef|PSGIBody]
67 ];
68 1;
69  
70  
71 =pod
72  
73 =head1 NAME
74  
75 POEx::Types::PSGIServer - Provides type constraints for use in POEx::Role::PSGIServer
76  
77 =head1 VERSION
78  
79 version 1.110670
80  
81 =head1 TYPES
82  
83 =head2 PSGIServerContext
84  
85 PSGIServerContext is defined as a Hash with the following keys:
86  
87 request => HTTPRequest,
88 wheel => Optional[Wheel],
89 version => Str,
90 protocol => Str,
91 connection => Str,
92 keep_alive => Bool,
93 chunked => Optional[Bool],
94 explicit_length => Optional[Bool],
95  
96 The context is passed around to identify the current connection and what it is expecting
97  
98 =head2 HTTPRequest
99  
100 This is a simple class_type for HTTP::Request
101  
102 =head2 HTTPCode
103  
104 This constraint uses HTTP::Status to check if the Int is a valid HTTP::Status code
105  
106 =head2 PSGIBody
107  
108 The PSGIBody constraint covers two of the three types of body responses valid for PGSI responses: a real filehandle or a blessed reference that duck-types getline and close
109  
110 =head2 PSGIResponse
111  
112 This constraint checks responses from PSGI applications for a valid HTTPCode, an ArrayRef of headers, and the Optional PSGIBody or ArrayRef body
113  
114 =head1 AUTHOR
115  
116 Nicholas Perez <nperez@cpan.org>
117  
118 =head1 COPYRIGHT AND LICENSE
119  
120 This software is copyright (c) 2011 by Infinity Interactive.
121  
122 This is free software; you can redistribute it and/or modify it under
123 the same terms as the Perl 5 programming language system itself.
124  
125 =cut
126  
127  
128 __END__