line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Middleware::DebugRequest; |
2
|
1
|
|
|
1
|
|
429
|
use HTTP::Engine::Middleware; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
5
|
use Text::SimpleTable; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
286
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with 'HTTP::Engine::Middleware::Role::Logger'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
before_handle { |
8
|
|
|
|
|
|
|
my ( $c, $self, $req ) = @_; |
9
|
|
|
|
|
|
|
$self->report_request_info($req); |
10
|
|
|
|
|
|
|
$req; |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub report_request_info { |
14
|
3
|
|
|
3
|
0
|
3
|
my ( $self, $request ) = @_; |
15
|
3
|
|
|
|
|
6
|
$self->report_request_basic_info($request); |
16
|
3
|
|
|
|
|
25
|
$self->report_params($request); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub report_params { |
20
|
3
|
|
|
3
|
0
|
4
|
my ( $self, $req ) = @_; |
21
|
3
|
100
|
|
|
|
4
|
if ( keys %{ $req->parameters } ) { |
|
3
|
|
|
|
|
18
|
|
22
|
2
|
|
|
|
|
510
|
my $t |
23
|
|
|
|
|
|
|
= Text::SimpleTable->new( [ 20, 'Parameter' ], [ 36, 'Value' ] ); |
24
|
2
|
|
|
|
|
67
|
for my $key ( sort keys %{ $req->parameters } ) { |
|
2
|
|
|
|
|
8
|
|
25
|
2
|
|
|
|
|
4
|
my $param = $req->parameters->{$key}; |
26
|
2
|
50
|
|
|
|
5
|
my $value = defined($param) ? $param : ''; |
27
|
2
|
50
|
|
|
|
7
|
$t->row( $key, |
28
|
|
|
|
|
|
|
ref $value eq 'ARRAY' ? ( join ', ', @$value ) : $value ); |
29
|
|
|
|
|
|
|
} |
30
|
2
|
|
|
|
|
72
|
my $message = "Parameters: \n" . $t->draw; |
31
|
2
|
|
|
|
|
146
|
$self->log( $message ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub report_request_basic_info { |
36
|
3
|
|
|
3
|
0
|
4
|
my ( $self, $req ) = @_; |
37
|
3
|
|
|
|
|
22
|
my $t = Text::SimpleTable->new( |
38
|
|
|
|
|
|
|
[ 40, 'Path' ], |
39
|
|
|
|
|
|
|
[ 8, 'Method' ], |
40
|
|
|
|
|
|
|
[ 30, 'Base' ] |
41
|
|
|
|
|
|
|
); |
42
|
3
|
|
|
|
|
165
|
$t->row( $req->path, $req->method, $req->base ); |
43
|
3
|
|
|
|
|
329
|
my $message = "Matching Info:\n" . $t->draw; |
44
|
3
|
|
|
|
|
354
|
$self->log( $message ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__MIDDLEWARE__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
HTTP::Engine::Middleware::DebugRequest - dump request |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $mw = HTTP::Engine::Middleware->new; |
58
|
|
|
|
|
|
|
$mw->install( 'HTTP::Engine::Middleware::DebugRequest' => { |
59
|
|
|
|
|
|
|
logger => sub { |
60
|
|
|
|
|
|
|
warn @_; |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
}); |
63
|
|
|
|
|
|
|
HTTP::Engine->new( |
64
|
|
|
|
|
|
|
interface => { |
65
|
|
|
|
|
|
|
module => 'YourFavoriteInterfaceHere', |
66
|
|
|
|
|
|
|
request_handler => $mw->handler( \&handler ), |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
)->run(); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This middleware prints request info like Catalyst. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
dann |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L<HTTP::Engine::Middleware> |
81
|
|
|
|
|
|
|
|