line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package API::Matterbridge; |
2
|
1
|
|
|
1
|
|
714
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
7
|
use Moo::Role 2; |
|
1
|
|
|
|
|
32
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
447
|
use Filter::signatures; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
18
|
|
7
|
1
|
|
|
1
|
|
35
|
use feature 'signatures'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
8
|
1
|
|
|
1
|
|
7
|
no warnings 'experimental::signatures'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
10
|
use URI; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
488
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
requires 'build_request', 'short_ua', 'stream_ua'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SEE ALSO |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
L |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Naah, this should move straight to Mojolicious |
23
|
|
|
|
|
|
|
# instead of separating out a protocol module that can be used elsewhere ... |
24
|
|
|
|
|
|
|
# The message stream (via /api/stream) needs special async handling and can't |
25
|
|
|
|
|
|
|
# be used with (for example) LWP |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'url' => ( |
28
|
|
|
|
|
|
|
is => 'lazy', |
29
|
|
|
|
|
|
|
default => sub { URI->new( 'http://localhost:4242/api/' ) }, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'health_url' => ( |
33
|
|
|
|
|
|
|
is => 'lazy', |
34
|
|
|
|
|
|
|
default => sub { URI->new( $_[0]->url . 'health' ) }, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'message_url' => ( |
38
|
|
|
|
|
|
|
is => 'lazy', |
39
|
|
|
|
|
|
|
default => sub { URI->new( $_[0]->url . 'message' ) }, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'messages_url' => ( |
43
|
|
|
|
|
|
|
is => 'lazy', |
44
|
|
|
|
|
|
|
default => sub { URI->new( $_[0]->url . 'messages' ) }, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'stream_url' => ( |
48
|
|
|
|
|
|
|
is => 'lazy', |
49
|
|
|
|
|
|
|
default => sub { URI->new( $_[0]->url . 'stream' ) }, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has 'json' => ( |
53
|
|
|
|
|
|
|
is => 'lazy', |
54
|
|
|
|
|
|
|
default => sub { |
55
|
|
|
|
|
|
|
require JSON; |
56
|
|
|
|
|
|
|
return JSON->new() |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
0
|
|
sub build_post_message( $self, %options ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->build_request( |
62
|
|
|
|
|
|
|
method => 'POST', |
63
|
|
|
|
|
|
|
url => $self->message_url, |
64
|
|
|
|
|
|
|
headers => { |
65
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
data => $self->json->encode( \%options ), |
68
|
|
|
|
|
|
|
ua => $self->short_ua, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
0
|
0
|
|
sub build_get_messages( $self ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$self->build_request( |
74
|
|
|
|
|
|
|
method => 'GET', |
75
|
|
|
|
|
|
|
url => $self->messages_url, |
76
|
|
|
|
|
|
|
ua => $self->short_ua, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
|
sub build_get_message_stream( $self ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$self->build_request( |
82
|
|
|
|
|
|
|
method => 'GET', |
83
|
|
|
|
|
|
|
url => $self->stream_url, |
84
|
|
|
|
|
|
|
ua => $self->stream_ua, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 REPOSITORY |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The public repository of this module is |
93
|
|
|
|
|
|
|
L. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SUPPORT |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The public support forum of this module is L. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 BUG TRACKER |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Please report bugs in this module via the Github bug queue at |
102
|
|
|
|
|
|
|
L |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Max Maischein C |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright 2020 by Max Maischein C. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 LICENSE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |