summaryrefslogblamecommitdiff
path: root/lib/Net/HTTP/Spore/Middleware.pm
blob: 2855a727d5bbf99b7c6e2e3f61172f440321d194 (plain) (tree)
1
2
3
4

                                     

                                  

















                               
                                  



                                  
 
                



                                      



      
package Net::HTTP::Spore::Middleware;

# ABSTRACT: middlewares base class

use strict;
use warnings;

sub new {
    my $class = shift;
    bless {@_}, $class;
}

sub response_cb {
    my ($self, $cb) = @_;

    my $body_filter = sub {
        my $filter = $cb->(@_);
    };
    return $body_filter;
}

sub wrap {
    my ($self, $cond, @args) = @_;

    if (!ref $self) {
        $self = $self->new(@args);
    }

    return sub {
        my $request = shift;
        if ($cond->($request)) {
            $self->call($request, @_);
        }
    };
}

1;