Exception-Reporter-Summarizer-PlackRequest
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Exception/Reporter/Summarizer/PlackRequest.pm view on Meta::CPAN
use strict;
use warnings;
package Exception::Reporter::Summarizer::PlackRequest;
$Exception::Reporter::Summarizer::PlackRequest::VERSION = '0.001';
use parent 'Exception::Reporter::Summarizer';
# ABSTRACT: a summarizer for Plack::Request objects
use Plack::Request;
#pod =head1 OVERVIEW
#pod
#pod If added as a summarizer to an L<Exception::Reporter>, this plugin will
#pod summarize L<Plack::Request> objects, adding a summary for the request.
#pod
#pod =cut
use Try::Tiny;
sub new {
my ($class, $arg) = @_;
$arg ||= {};
return bless { } => $class;
}
sub can_summarize {
my ($self, $entry) = @_;
return try { $entry->[1]->isa('Plack::Request') };
}
sub summarize {
my ($self, $entry) = @_;
my ($name, $req, $arg) = @$entry;
my @summaries;
push @summaries, $self->summarize_request($req);
return @summaries;
}
sub summarize_request {
my ($self, $req) = @_;
my %to_dump = map {
$_ => defined($req->$_) ? ($req->$_ . "") : undef,
} qw(
address
content_length
content_type
content_encoding
remote_host
protocol
method
port
user
request_uri
path_info
path
query_string
referer
user_agent
script_name
scheme
secure
);
$to_dump{upload} = [ $req->upload ];
$to_dump{cookies} = $req->cookies;
return {
filename => 'request.txt',
%{ $self->dump(\%to_dump, { basename => 'request' }) },
ident => 'plack request',
};
}
1;
__END__
=pod
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.852 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )