Throwable/Role/Status/MethodNotAllowed.pm

filter: Statementstmt 100% 34 / 34 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 95.5% 43 / 45 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Throwable/Role/Status/NotModified.pm ↑ Summary Throwable/Role/Redirect.pm »
1 package HTTP::Throwable::Role::Status::MethodNotAllowed;
2 2 our $AUTHORITY = 'cpan:STEVAN';
3 2 $HTTP::Throwable::Role::Status::MethodNotAllowed::VERSION = '0.027';
4 2 ▶use Type::Utils qw(subtype as where enum);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Types::Standard qw(ArrayRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use List::Util 1.45 qw[ uniq ];
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 with(
11 'HTTP::Throwable',
12 'HTTP::Throwable::Role::BoringText',
13 );
14  
15 2 my $method_enum_type = enum "HttpThrowableTypeMethod" => [ qw[
16 OPTIONS GET HEAD
17 POST PUT DELETE
18 TRACE CONNECT
19 ] ];
20  
21 # TODO: Consider adding a coersion to upper-case lower-cased strings and to
22 # uniq the given input. -- rjbs, 2011-02-21
23 my $method_list_type = subtype "HttpThrowableTypeMethodList",
24 as ArrayRef[ $method_enum_type ],
25 5 ▶ where { (scalar uniq @{$_}) == (scalar @{$_}) };
Subroutine __ANON__: called CC=1 SCAR=0.0
26  
27 3 ▶sub default_status_code { 405 }
Subroutine default_status_code: called CC=1 SCAR=0.0
Pod undocumented
28 3 ▶sub default_reason { 'Method Not Allowed' }
Subroutine default_reason: called CC=1 SCAR=0.0
Pod undocumented
29  
30 2 has 'allow' => (
31 is => 'ro',
32 isa => $method_list_type,
33 required => 1
34 );
35  
36 around 'build_headers' => sub {
37 3 ▶ my $next = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
38 3 my $self = shift;
39 3 my $headers = $self->$next( @_ );
40 3 push @$headers => ('Allow' => join "," => @{ $self->allow });
41 3 $headers;
42 2 };
43  
44  
45 2 ▶no Moo::Role; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 =pod
48  
49 =encoding UTF-8
50  
51 =head1 NAME
52  
53 HTTP::Throwable::Role::Status::MethodNotAllowed - 405 Method Not Allowed
54  
55 =head1 VERSION
56  
57 version 0.027
58  
59 =head1 DESCRIPTION
60  
61 The method specified in the Request-Line is not allowed for the
62 resource identified by the Request-URI. The response MUST include
63 an Allow header containing a list of valid methods for the requested
64 resource.
65  
66 =head1 ATTRIBUTES
67  
68 =head2 allow
69  
70 This is an ArrayRef of HTTP methods, it is required and the HTTP
71 methods will be type checked to ensure validity and uniqueness.
72  
73 =head1 SEE ALSO
74  
75 HTTP Methods - L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html>
76  
77 =head1 AUTHORS
78  
79 =over 4
80  
81 =item *
82  
83 Stevan Little <stevan.little@iinteractive.com>
84  
85 =item *
86  
87 Ricardo Signes <rjbs@cpan.org>
88  
89 =back
90  
91 =head1 COPYRIGHT AND LICENSE
92  
93 This software is copyright (c) 2011 by Infinity Interactive, Inc.
94  
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97  
98 =cut
99  
100 __END__
« Throwable/Role/Status/NotModified.pm ↑ Summary Throwable/Role/Redirect.pm »