Skip to content

Instantly share code, notes, and snippets.

@jrockway
Created May 2, 2011 12:23
Show Gist options
  • Save jrockway/951525 to your computer and use it in GitHub Desktop.
Save jrockway/951525 to your computer and use it in GitHub Desktop.
has 'request_builder' => (
is => 'ro',
isa => 'CodeRef',
traits => ['Code'],
handles => { request => 'execute' },
default => sub {
my ($self) = @_;
weaken $self;
return sub {
my ($method, $uri, $headers, $cb) = @_;
$headers ||= [];
my $guard;
weaken $guard;
$guard = http_request $method => $uri, @$headers, sub {
$self->delete_request($guard);
$cb->(@_);
};
$self->insert_request($guard);
return $guard;
};
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment