line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package API::Matterbridge; |
2
|
1
|
|
|
1
|
|
579
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
5
|
use Moo::Role 2; |
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
361
|
use Filter::signatures; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
36
|
use feature 'signatures'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
8
|
1
|
|
|
1
|
|
6
|
no warnings 'experimental::signatures'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use URI; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
397
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
requires 'build_request', 'short_ua', 'stream_ua'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
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; |