line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Interface; |
2
|
28
|
|
|
32
|
|
15069
|
use Any::Moose; |
|
28
|
|
|
|
|
68
|
|
|
28
|
|
|
|
|
282
|
|
3
|
|
|
|
|
|
|
use Any::Moose ( |
4
|
28
|
|
|
|
|
158
|
'::Util' => [qw/apply_all_roles/], |
5
|
28
|
|
|
30
|
|
17228
|
); |
|
28
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $ARGS; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init_class { |
10
|
64
|
|
|
64
|
0
|
135
|
my $klass = shift; |
11
|
64
|
|
|
|
|
267
|
my $meta = any_moose('::Meta::Class')->initialize($klass); |
12
|
64
|
50
|
|
|
|
4564
|
$meta->superclasses(any_moose('::Object')) |
13
|
|
|
|
|
|
|
unless $meta->superclasses; |
14
|
|
|
|
|
|
|
|
15
|
28
|
|
|
28
|
|
14784
|
no strict 'refs'; |
|
28
|
|
|
|
|
60
|
|
|
28
|
|
|
|
|
1008
|
|
16
|
28
|
|
|
28
|
|
148
|
no warnings 'redefine'; |
|
28
|
|
|
|
|
69
|
|
|
28
|
|
|
|
|
3550
|
|
17
|
64
|
|
|
87
|
|
5872
|
*{ $klass . '::meta' } = sub { $meta }; |
|
64
|
|
|
|
|
446
|
|
|
87
|
|
|
|
|
814
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
21
|
34
|
|
|
34
|
|
1759
|
my $class = shift; |
22
|
|
|
|
|
|
|
|
23
|
34
|
|
|
|
|
80
|
my $caller = caller(0); |
24
|
34
|
100
|
|
|
|
221
|
return if $caller eq 'main'; |
25
|
|
|
|
|
|
|
|
26
|
33
|
|
|
|
|
166
|
$ARGS->{$caller} = {@_}; |
27
|
|
|
|
|
|
|
|
28
|
28
|
|
|
28
|
|
158
|
no strict 'refs'; |
|
28
|
|
|
|
|
64
|
|
|
28
|
|
|
|
|
25288
|
|
29
|
33
|
|
|
|
|
200
|
*{"$caller\::__INTERFACE__"} = sub { |
30
|
33
|
|
|
33
|
|
145
|
my $caller = caller(0); |
31
|
33
|
|
|
|
|
152
|
__INTERFACE__($caller); |
32
|
33
|
|
|
|
|
136
|
}; |
33
|
|
|
|
|
|
|
|
34
|
33
|
|
|
|
|
473
|
strict->import; |
35
|
33
|
|
|
|
|
304
|
warnings->import; |
36
|
|
|
|
|
|
|
|
37
|
33
|
|
|
|
|
93
|
init_class($caller); |
38
|
|
|
|
|
|
|
|
39
|
33
|
|
|
|
|
119
|
any_moose()->import({into_level => 1}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# fix up Interface. |
43
|
|
|
|
|
|
|
sub __INTERFACE__ { |
44
|
33
|
|
|
33
|
|
78
|
my ($caller, ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
33
|
|
|
|
|
68
|
my %args = %{ delete $ARGS->{$caller} }; |
|
33
|
|
|
|
|
253
|
|
47
|
|
|
|
|
|
|
|
48
|
33
|
100
|
|
|
|
303
|
my $builder = delete $args{builder} or die "missing builder"; |
49
|
32
|
100
|
|
|
|
248
|
my $writer = delete $args{writer} or die "missing writer"; |
50
|
|
|
|
|
|
|
|
51
|
31
|
|
|
|
|
169
|
_setup_builder($caller, $builder); |
52
|
31
|
|
|
|
|
938
|
_setup_writer($caller, $writer); |
53
|
|
|
|
|
|
|
|
54
|
31
|
|
|
|
|
926
|
apply_all_roles($caller, 'HTTP::Engine::Role::Interface'); |
55
|
|
|
|
|
|
|
|
56
|
30
|
|
|
|
|
22871
|
$caller->meta->make_immutable(inline_destructor => 1); |
57
|
|
|
|
|
|
|
|
58
|
30
|
|
|
|
|
3069
|
"END_OF_MODULE"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _setup_builder { |
62
|
31
|
|
|
31
|
|
81
|
my ($caller, $builder ) = @_; |
63
|
31
|
100
|
|
|
|
230
|
$builder = ($builder =~ s/^\+(.+)$//) ? $1 : "HTTP::Engine::RequestBuilder::$builder"; |
64
|
31
|
100
|
|
|
|
686
|
unless ($builder->can('meta')) { |
65
|
2
|
|
|
|
|
8
|
Any::Moose::load_class($builder); |
66
|
2
|
50
|
|
|
|
27
|
$@ and die $@; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
31
|
|
|
|
|
567
|
my $instance = $builder->new; |
70
|
31
|
|
|
41
|
|
2764
|
$caller->meta->add_method(request_builder => sub { $instance }); |
|
41
|
|
|
41
|
|
1324
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _setup_writer { |
74
|
31
|
|
|
31
|
|
83
|
my ($caller, $args) = @_; |
75
|
|
|
|
|
|
|
|
76
|
31
|
|
|
|
|
127
|
my $writer = _construct_writer($caller, $args)->new; |
77
|
|
|
|
|
|
|
|
78
|
31
|
|
|
41
|
|
2389
|
$caller->meta->add_method(response_writer => sub { $writer }); |
|
41
|
|
|
41
|
|
591
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _construct_writer { |
82
|
31
|
|
|
35
|
|
74
|
my ($caller, $args, ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
31
|
|
|
|
|
95
|
my $writer = $caller . '::ResponseWriter'; |
85
|
31
|
|
|
|
|
118
|
init_class($writer); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
{ |
88
|
31
|
50
|
33
|
|
|
66
|
$writer->meta->make_mutable |
|
31
|
|
|
|
|
157
|
|
89
|
|
|
|
|
|
|
if Any::Moose::moose_is_preferred() |
90
|
|
|
|
|
|
|
&& $writer->meta->is_immutable; |
91
|
|
|
|
|
|
|
|
92
|
31
|
|
|
|
|
274
|
my @roles; |
93
|
31
|
|
|
100
|
|
153
|
my $apply = sub { push @roles, "HTTP::Engine::Role::ResponseWriter::$_[0]" }; |
|
97
|
|
|
|
|
275
|
|
94
|
31
|
50
|
|
|
|
148
|
if ($args->{finalize}) { |
95
|
0
|
|
|
|
|
0
|
$writer->meta->add_method(finalize => $args->{finalize}); |
96
|
|
|
|
|
|
|
} else { |
97
|
31
|
50
|
|
|
|
148
|
if ($args->{response_line}) { |
98
|
0
|
|
|
|
|
0
|
$apply->('ResponseLine'); |
99
|
|
|
|
|
|
|
} |
100
|
31
|
100
|
|
|
|
244
|
if (my $code = $args->{output_header}) { |
101
|
13
|
|
|
|
|
102
|
$writer->meta->add_method(output_header => $code); |
102
|
|
|
|
|
|
|
} else { |
103
|
18
|
|
|
|
|
57
|
$apply->('OutputHeader'); |
104
|
|
|
|
|
|
|
} |
105
|
31
|
100
|
|
|
|
141
|
if (my $code = $args->{output_body}) { |
106
|
1
|
|
|
|
|
5
|
$writer->meta->add_method(output_body => $code); |
107
|
|
|
|
|
|
|
} else { |
108
|
30
|
|
|
|
|
101
|
$apply->('OutputBody'); |
109
|
|
|
|
|
|
|
} |
110
|
31
|
100
|
|
|
|
160
|
if (my $code = $args->{write}) { |
111
|
13
|
|
|
|
|
60
|
$writer->meta->add_method(write => $code); |
112
|
|
|
|
|
|
|
} else { |
113
|
18
|
|
|
|
|
52
|
$apply->('WriteSTDOUT'); |
114
|
|
|
|
|
|
|
} |
115
|
31
|
|
|
|
|
111
|
$apply->('Finalize'); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
31
|
|
|
|
|
98
|
for my $role (@roles, 'HTTP::Engine::Role::ResponseWriter') { |
119
|
128
|
|
|
|
|
49386
|
apply_all_roles($writer, $role); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
31
|
50
|
|
|
|
13065
|
for my $before (keys %{ $args->{before} || {} }) { |
|
31
|
|
|
|
|
407
|
|
124
|
0
|
|
|
|
|
0
|
$writer->meta->add_before_method_modifier( $before => $args->{before}->{$before} ); |
125
|
|
|
|
|
|
|
} |
126
|
31
|
100
|
|
|
|
95
|
for my $around (keys %{ $args->{around} || {} }) { |
|
31
|
|
|
|
|
233
|
|
127
|
15
|
|
|
|
|
76
|
$writer->meta->add_around_method_modifier( $around => $args->{around}->{$around} ); |
128
|
|
|
|
|
|
|
} |
129
|
31
|
100
|
|
|
|
869
|
for my $attribute (keys %{ $args->{attributes} || {} }) { |
|
31
|
|
|
|
|
243
|
|
130
|
14
|
|
|
|
|
101
|
$writer->meta->add_attribute( |
131
|
|
|
|
|
|
|
$attribute, |
132
|
14
|
|
|
|
|
55
|
%{ $args->{attributes}->{$attribute} } |
133
|
|
|
|
|
|
|
) |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# FIXME |
137
|
31
|
50
|
|
|
|
2086
|
$writer->meta->make_immutable(inline_destructor => 1) |
138
|
|
|
|
|
|
|
unless Any::Moose::moose_is_preferred(); |
139
|
|
|
|
|
|
|
|
140
|
31
|
|
|
|
|
2572
|
return $writer; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |