| 1 | package Plack::Middleware::Dispatch::GP::Request; | ||||||||||||||||||||
| 2 | 1 | $Plack::Middleware::Dispatch::GP::Request::VERSION = '0.01'; | |||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | Plack::Middleware::Dispatch::GP::Request - dispatcher middleware for general purposes request handling | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 DESCRIPTION | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | The module is derived from C<Plack::Middleware::Dispatch::GP>. It provides Plack::Request to registered dispatchers | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | Version 0.01 | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | ▶ | use parent "Plack::Middleware::Dispatch::GP"; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 1 | ▶ | use Plack::Util::Accessor qw/ | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | dispatch | ||||||||||||||||||||
| 24 | 1 | /; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 1 | ▶ | use Plack::Request (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | use Plack::Builder; | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | my $foo = Foo->new() # Foo should provide dispatch method | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | my $app = sub { ... }; | ||||||||||||||||||||
| 36 | builder { | ||||||||||||||||||||
| 37 | enable "Dispatch", dispatch => [\&cb, $foo]; | ||||||||||||||||||||
| 38 | $app; | ||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | # cb(Plack::Request) | ||||||||||||||||||||
| 42 | sub cb { | ||||||||||||||||||||
| 43 | my($req) = @_; | ||||||||||||||||||||
| 44 | ... | ||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head2 new($p) | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | see L<Plack::Middleware::Dispatch::GP> | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 57 | 0 | my $proto = shift; | |||||||||||||||||||
| 58 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 59 | 0 | return $class->SUPER::new(@_); | |||||||||||||||||||
| 60 | } ## end sub new | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head2 call($env) | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | delivers Plack::Request->new($env) to the dispatchers | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | ▶ | sub call { | ||||||||||||||||||
|
Subroutine
call: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 69 | 0 | my ($self, $env) = @_; | |||||||||||||||||||
| 70 | 0 | my $req = Plack::Request->new($env); | |||||||||||||||||||
| 71 | 0 | $self->_dispatch($req); | |||||||||||||||||||
| 72 | # foreach my $d (@{ $self->dispatch }) { | ||||||||||||||||||||
| 73 | # $d->($req); | ||||||||||||||||||||
| 74 | # } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | $self->app->($env); | |||||||||||||||||||
| 77 | } ## end sub call | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 1 | 1; # End of Plack::Middleware::Dispatch::GP::Request | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =head1 AUTHOR | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | Alexei Pastuchov, C<< <palik at cpan.org> >> | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =head1 REPOSITORY | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | L<https://github.com/p-alik/Plack-Middleware-Dispatch-GP> | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =head1 SUPPORT | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | perldoc Plack::Middleware::Dispatch::GP::Request | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | Copyright 2015 Alexei Pastuchov. | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 100 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||||
| 101 | copy of the full license at: | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||||
| 106 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||||
| 107 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||||
| 108 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||||
| 111 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||||
| 112 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||||
| 115 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||||
| 118 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||||||||
| 119 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||||
| 120 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||||
| 121 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||||
| 122 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||||
| 123 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||||
| 124 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||||
| 127 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||||
| 128 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||||
| 129 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||||
| 130 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||||
| 131 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||||
| 132 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||||
| 133 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||