k web applications
=head1 VERSION
version 0.03
=head1 SYNOPSIS
use Plack::Builder;
use JSON;
use Plack::Debugger;
use Plack::Debugger::Storage;
use Plack::App::Debugger;
us
panel',
serializer => sub { encode_json( shift ) },
deserializer => sub { decode_json( shift ) },
filename_fmt => "%s.json",
),
panels => [
Plack:
he necessary javascript and CSS for the debugging
UI. The second is to provide a small REST style JSON web-service that
serves up the debugging data.
=head2 C<Plack.Debugger>
This is the javascript
e JSON::XS;
our $VERSION = '0.03';
our $AUTHORITY = 'cpan:STEVAN';
use parent 'Exporter';
our @EXPORT = qw[
result_generator
create_root
create_child
];
our $FILENAME_FMT = '%s.json';
our $JSON = JSON::XS->new->utf8->pretty;
{
my $UID_SEQ = 0;
my $UID_FMT = '%04d';
sub next_UID { sprintf $UID_FMT, ++$UID_SEQ }
}
sub result_generator {
my ($uid, $parent_u
my $root_uid = next_UID;
$dir->file( sprintf $FILENAME_FMT => $root_uid )
->spew( $JSON->encode( result_generator( $root_uid ) ) );
return $root_uid;
}
sub create_child {
my $d
and pass them
# through
return $resp;
}
sub handle_json_content_type {
my ($self, $env, $resp) = @_;
# application/json responses really
# can't get injected into so we
#
);
}
elsif ( $content_type =~ m!^(?:application/json)! ) {
return $self->handle_json_content_type( $env, $resp );
}
# now be less spec
ess the stream and if a closing C<<body>> tag is found, inject
accordingly.
=item C<application/json>
While we have a specific handler for this content-type, we do not do
anything but just let it
use Try::Tiny;
use Scalar::Util qw[ blessed ];
use File::ShareDir;
use File::Spec::Unix ();
use JSON::XS ();
use Plack::App::File;
use Plack::Debugger;
our $VERSION = '0.03';
our $AUTHO
debugger';
# Be *extremely* lax about our JSON, this
# might be overkill for simple cases, but
# for non-simple cases, it just makes sense.
our $JSON = JSON::XS
->new
c_app'} = Plack::App::File->new( root => $args{'static_asset_dir'} )->to_app;
$args{'_JSON'} = $JSON;
$class->SUPER::new( %args );
}
# accessors ...
sub debugger { (shift)->{'