| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::WebSocketProxy::Config; |
|
2
|
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
94
|
use strict; |
|
|
17
|
|
|
|
|
25
|
|
|
|
17
|
|
|
|
|
396
|
|
|
4
|
17
|
|
|
17
|
|
66
|
use warnings; |
|
|
17
|
|
|
|
|
30
|
|
|
|
17
|
|
|
|
|
400
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
62
|
use Mojo::Base -base; |
|
|
17
|
|
|
|
|
26
|
|
|
|
17
|
|
|
|
|
79
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.11'; ## VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 METHODS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 init |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Applies configuration. Supports the following config vars: |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=over 4 |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=item * opened_connection - coderef which will be called when a new connection is opened |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item * finish_connection - coderef called on connection close |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item * skip_check_sanity - actions for which sanity checks will not be applied |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=back |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Returns an empty list. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
|
33
|
22
|
|
|
22
|
1
|
51
|
my ($self, $in_config) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
22
|
|
|
|
|
94
|
$self->{config} = {}; |
|
36
|
22
|
|
|
|
|
50
|
$self->{actions} = {}; |
|
37
|
22
|
|
|
|
|
43
|
$self->{backends} = {}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
22
|
50
|
33
|
|
|
97
|
die 'Expected a coderef for opened_connection' if $in_config->{opened_connection} && ref($in_config->{opened_connection}) ne 'CODE'; |
|
40
|
22
|
50
|
33
|
|
|
104
|
die 'Expected a coderef for finish_connection' if $in_config->{finish_connection} && ref($in_config->{finish_connection}) ne 'CODE'; |
|
41
|
22
|
50
|
33
|
|
|
76
|
die 'Expected a regex for skip_check_sanity' if $in_config->{skip_check_sanity} && ref($in_config->{skip_check_sanity}) ne 'Regexp'; |
|
42
|
|
|
|
|
|
|
|
|
43
|
22
|
|
|
|
|
49
|
$self->{config} = $in_config; |
|
44
|
22
|
|
|
|
|
42
|
return; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 add_action |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Adds an action to the list of handlers. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Expects C<$action> as an arrayref, and an C<$order> in which the action should be applied. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub add_action { |
|
56
|
30
|
|
|
30
|
1
|
62
|
my ($self, $action, $order) = @_; |
|
57
|
30
|
|
|
|
|
53
|
my $name = $action->[0]; |
|
58
|
30
|
|
|
|
|
43
|
my $options = $action->[1]; |
|
59
|
|
|
|
|
|
|
|
|
60
|
30
|
|
66
|
|
|
139
|
$self->{actions}->{$name} ||= $options; |
|
61
|
30
|
|
|
|
|
59
|
$self->{actions}->{$name}->{order} = $order; |
|
62
|
30
|
|
|
|
|
48
|
$self->{actions}->{$name}->{name} = $name; |
|
63
|
30
|
|
|
|
|
78
|
return; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub add_backend { |
|
67
|
24
|
|
|
24
|
1
|
58
|
my ($self, $name, $backend) = @_; |
|
68
|
24
|
|
|
|
|
50
|
$self->{backends}{$name} = $backend; |
|
69
|
24
|
|
|
|
|
48
|
return; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |