line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::JSON::RPC::Dispatcher::Method; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
15
|
use Mojo::Base -base; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
19
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has id => undef; |
6
|
|
|
|
|
|
|
has method => undef; |
7
|
|
|
|
|
|
|
has params => undef; |
8
|
|
|
|
|
|
|
has result => undef; |
9
|
|
|
|
|
|
|
has is_notification => 0; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has error_code => undef; |
12
|
|
|
|
|
|
|
has error_message => undef; |
13
|
|
|
|
|
|
|
has error_data => undef; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub clear_error { |
16
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
17
|
0
|
|
|
|
|
0
|
return $self->error( undef, undef, undef ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub error { |
21
|
15
|
|
|
15
|
1
|
28
|
my ( $self, $code, $message, $data ) = @_; |
22
|
15
|
|
|
|
|
36
|
$self->error_code($code); |
23
|
15
|
|
|
|
|
88
|
$self->error_message($message); |
24
|
15
|
|
|
|
|
76
|
$self->error_data($data); |
25
|
15
|
|
|
|
|
72
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub has_error { |
29
|
89
|
|
|
89
|
1
|
305
|
my ($self) = @_; |
30
|
89
|
|
|
|
|
122
|
return !!$self->error_code; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub internal_error { |
34
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $msg ) = @_; |
35
|
0
|
|
|
|
|
0
|
return $self->error( -32603, 'Internal error.', $msg ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub invalid_params { |
39
|
1
|
|
|
1
|
1
|
9
|
my ( $self, $msg ) = @_; |
40
|
1
|
|
|
|
|
4
|
return $self->error( -32602, 'Invalid params.', $msg ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub invalid_request { |
44
|
10
|
|
|
10
|
1
|
64
|
my ( $self, $msg ) = @_; |
45
|
10
|
|
|
|
|
22
|
return $self->error( -32600, 'Invalid Request.', $msg ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub method_not_found { |
49
|
2
|
|
|
2
|
1
|
10
|
my ( $self, $msg ) = @_; |
50
|
2
|
|
|
|
|
6
|
return $self->error( -32601, 'Method not found.', $msg ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub parse_error { |
54
|
2
|
|
|
2
|
1
|
15
|
my ( $self, $msg ) = @_; |
55
|
2
|
|
|
|
|
5
|
return $self->error( -32700, 'Parse error.', $msg ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub response { |
59
|
40
|
|
|
40
|
1
|
58
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
return { |
61
|
40
|
50
|
|
|
|
93
|
jsonrpc => '2.0', |
|
|
100
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$self->is_notification ? () : ( id => $self->id ), |
63
|
|
|
|
|
|
|
$self->has_error |
64
|
|
|
|
|
|
|
? ( error => { |
65
|
|
|
|
|
|
|
code => $self->error_code, |
66
|
|
|
|
|
|
|
message => $self->error_message, |
67
|
|
|
|
|
|
|
data => $self->error_data, |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
) |
70
|
|
|
|
|
|
|
: ( result => $self->result ) |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |