line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Debugbar; |
2
|
1
|
|
|
1
|
|
67699
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
200144
|
|
|
1
|
|
|
|
|
10
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1550
|
use Mojo::Debugbar; |
|
1
|
|
|
|
|
48365
|
|
|
1
|
|
|
|
|
11
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.0.2'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head2 register |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub register { |
13
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $config) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $debugbar = Mojo::Debugbar->new(app => $app, config => $config); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$app->hook(around_dispatch => sub { |
18
|
0
|
|
|
0
|
|
|
my ($next, $c) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Start recording |
21
|
0
|
|
|
|
|
|
$debugbar->start; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$next->(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Stop recording |
26
|
0
|
|
|
|
|
|
$debugbar->stop; |
27
|
0
|
|
|
|
|
|
}); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$app->hook(after_dispatch => sub { |
30
|
0
|
|
|
0
|
|
|
my $c = shift; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
0
|
|
|
|
if (!$c->stash('mojo.static') && !$c->res->is_redirect && $c->res->body =~ m/<\/body>/) { |
|
|
|
0
|
|
|
|
|
33
|
|
|
|
|
|
|
# Render the debugbar html |
34
|
0
|
|
|
|
|
|
my $html = $debugbar->render; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $body = $c->res->body; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Inject the debugbar html |
39
|
0
|
|
|
|
|
|
$body =~ s/<\/body>/$html\n<\/body>/ig; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Set the new body html |
42
|
0
|
|
|
|
|
|
$c->res->body($body); |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |