line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RestAPI::Endpoint; |
2
|
9
|
|
|
9
|
|
32
|
use Moo; |
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
77
|
|
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
2103
|
use Types::Standard qw(Enum Str); |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
39
|
|
5
|
9
|
|
|
9
|
|
3535
|
use Data::Dumper; |
|
9
|
|
|
|
|
4169
|
|
|
9
|
|
|
|
|
443
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
3542
|
use parent 'Exporter'; |
|
9
|
|
|
|
|
2110
|
|
|
9
|
|
|
|
|
40
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(convert_path_to_filename); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Test::RestAPI::Endpoint - API endpoint |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This class describe API endpoint. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 FUNCTIONS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 convert_path_to_filename($path) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
sub convert_path_to_filename { |
25
|
11
|
|
|
11
|
1
|
18
|
my ($path) = @_; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
67
|
$path =~ s/\W+/_/g; |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
|
|
|
63
|
return $path; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new(%attribute) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 %attribute |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head4 path |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
L paths |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
for more examples see L |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
default is '/' (root) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
has 'path' => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => Str, |
50
|
|
|
|
|
|
|
default => '/', |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head4 method |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
HTTP method |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
support are C|C|C|C|C|C|C |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
default is C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
has 'method' => ( |
63
|
|
|
|
|
|
|
is => 'ro', |
64
|
|
|
|
|
|
|
isa => Enum [qw(get head options path post put any)], |
65
|
|
|
|
|
|
|
default => 'get', |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head4 render |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
same arguments as L C method |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
has 'render' => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 render_as_string |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
sub render_as_string { |
81
|
8
|
|
|
8
|
1
|
46
|
my ($self) = @_; |
82
|
|
|
|
|
|
|
|
83
|
8
|
|
|
|
|
90
|
my $dumper = Data::Dumper->new([$self->render]); |
84
|
8
|
|
|
|
|
286
|
$dumper->Indent(0); |
85
|
8
|
|
|
|
|
130
|
$dumper->Terse(1); |
86
|
|
|
|
|
|
|
|
87
|
8
|
|
|
|
|
52
|
return $dumper->Dump(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 path_as_filename |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
sub path_as_filename { |
94
|
8
|
|
|
8
|
1
|
14512
|
my ($self) = @_; |
95
|
|
|
|
|
|
|
|
96
|
8
|
|
|
|
|
40
|
return convert_path_to_filename($self->path); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright (C) Avast Software. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
104
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Jan Seidl Eseidl@avast.comE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |