| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTPEx::Declare; |
|
2
|
3
|
|
|
3
|
|
36378
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
116
|
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
139
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
5
|
3
|
|
|
3
|
|
3810
|
use HTTP::Engine; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use HTTP::Engine::Response; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub compat_exports { |
|
9
|
|
|
|
|
|
|
require HTTP::Engine::Compat; |
|
10
|
|
|
|
|
|
|
HTTP::Engine::Compat->import; |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
|
|
|
|
|
|
middlewares => \&middlewares, |
|
13
|
|
|
|
|
|
|
interface => \&interface, |
|
14
|
|
|
|
|
|
|
run => \&run, |
|
15
|
|
|
|
|
|
|
}; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Sub::Exporter -setup => { |
|
19
|
|
|
|
|
|
|
exports => [qw/ middlewares interface run res /], |
|
20
|
|
|
|
|
|
|
groups => { |
|
21
|
|
|
|
|
|
|
default => [qw/ interface run res /], |
|
22
|
|
|
|
|
|
|
Compat => \&compat_exports, |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my ($module, $args); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub middlewares (@) { HTTP::Engine::Compat->load_middlewares(@_) } |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub interface ($$) { ( $module, $args ) = @_ } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub run (&;@) { |
|
33
|
|
|
|
|
|
|
unless ($module && $args) { |
|
34
|
|
|
|
|
|
|
require Carp; |
|
35
|
|
|
|
|
|
|
Carp::croak 'please define interface previously'; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
my $request_handler = shift; |
|
38
|
|
|
|
|
|
|
my $engine = HTTP::Engine->new( |
|
39
|
|
|
|
|
|
|
interface => { |
|
40
|
|
|
|
|
|
|
module => $module, |
|
41
|
|
|
|
|
|
|
args => $args, |
|
42
|
|
|
|
|
|
|
request_handler => sub { |
|
43
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
44
|
|
|
|
|
|
|
local *_res = sub { HTTP::Engine::Response->new(@_) }; |
|
45
|
|
|
|
|
|
|
$request_handler->(@_); |
|
46
|
|
|
|
|
|
|
}, |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
undef $module; |
|
50
|
|
|
|
|
|
|
undef $args; |
|
51
|
|
|
|
|
|
|
$engine->run(@_); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub res { goto &_res; } |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _res { |
|
57
|
|
|
|
|
|
|
require Carp; |
|
58
|
|
|
|
|
|
|
Carp::croak "Can't call res() outside run block"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
__END__ |