line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::RPC::Lite; |
2
|
3
|
|
|
3
|
|
160137
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
128
|
|
3
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
103
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
2512
|
use version; our $VERSION = version->declare("v1.0.0"); |
|
3
|
|
|
|
|
28209
|
|
|
3
|
|
|
|
|
196
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
7492
|
use JSON::RPC::Spec; |
|
3
|
|
|
|
|
356811
|
|
|
3
|
|
|
|
|
162
|
|
8
|
3
|
|
|
3
|
|
6290
|
use Plack::Request; |
|
3
|
|
|
|
|
252839
|
|
|
3
|
|
|
|
|
492
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
3
|
|
|
3
|
|
41
|
my $pkg = caller(0); |
12
|
3
|
|
|
|
|
34
|
my $rpc = JSON::RPC::Spec->new; |
13
|
|
|
|
|
|
|
my $method = sub ($$) { |
14
|
2
|
|
|
2
|
|
195
|
$rpc->register(@_); |
15
|
3
|
|
|
|
|
17933
|
}; |
16
|
3
|
|
|
3
|
|
42
|
no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
623
|
|
17
|
3
|
|
|
|
|
10
|
*{"${pkg}::method"} = $method; |
|
3
|
|
|
|
|
26
|
|
18
|
3
|
|
|
|
|
6278
|
*{"${pkg}::as_psgi_app"} = sub { |
19
|
|
|
|
|
|
|
return sub { |
20
|
3
|
|
|
3
|
|
79866
|
my $req = Plack::Request->new(@_); |
21
|
3
|
|
|
|
|
44
|
my $body = $rpc->parse($req->content); |
22
|
3
|
|
|
|
|
13415
|
my $header = ['Content-Type' => 'application/json']; |
23
|
3
|
100
|
|
|
|
19
|
if (length $body) { |
24
|
2
|
|
|
|
|
33
|
return [200, $header, [$body]]; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
|
|
|
|
11
|
return [204, [], []]; |
27
|
2
|
|
|
2
|
|
1635
|
}; |
28
|
3
|
|
|
|
|
13
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |