| 1 | package Net::HTTP::Spore::Middleware; | ||||||||||
| 2 | 37 | $Net::HTTP::Spore::Middleware::VERSION = '0.09'; | |||||||||
| 3 | # ABSTRACT: middlewares base class | ||||||||||
| 4 | |||||||||||
| 5 | 37 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 37 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 37 | ▶ | use Scalar::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 39 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 10 | 39 | my $class = shift; | |||||||||
| 11 | 39 | bless {@_}, $class; | |||||||||
| 12 | } | ||||||||||
| 13 | |||||||||||
| 14 | 9 | ▶ | sub response_cb { | ||||||||
|
Subroutine
response_cb: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 15 | 9 | my ($self, $cb) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 9 | ▶ | my $body_filter = sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 9 | my $filter = $cb->(@_); | |||||||||
| 19 | 9 | }; | |||||||||
| 20 | 9 | return $body_filter; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 41 | ▶ | sub wrap { | ||||||||
|
Subroutine
wrap: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 24 | 41 | my ($self, $cond, @args) = @_; | |||||||||
| 25 | |||||||||||
| 26 | 41 | ▶ | if (!Scalar::Util::blessed($self)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 39 | $self = $self->new(@args); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 45 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 31 | 45 | my $request = shift; | |||||||||
| 32 | 45 | ▶ | if ($cond->($request)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 44 | $self->call($request, @_); | |||||||||
| 34 | } | ||||||||||
| 35 | 41 | }; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 37 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||