line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RestAPI::Endpoint; |
2
|
9
|
|
|
9
|
|
57
|
use Moo; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
111
|
|
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
3803
|
use Types::Standard qw(Enum Str); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
67
|
|
5
|
9
|
|
|
9
|
|
5534
|
use Data::Dumper; |
|
9
|
|
|
|
|
6444
|
|
|
9
|
|
|
|
|
932
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
6280
|
use parent 'Exporter'; |
|
9
|
|
|
|
|
4191
|
|
|
9
|
|
|
|
|
73
|
|
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
|
35
|
my ($path) = @_; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
117
|
$path =~ s/\W+/_/g; |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
|
|
|
127
|
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
|
78
|
my ($self) = @_; |
82
|
|
|
|
|
|
|
|
83
|
8
|
|
|
|
|
140
|
my $dumper = Data::Dumper->new([$self->render]); |
84
|
8
|
|
|
|
|
450
|
$dumper->Indent(0); |
85
|
8
|
|
|
|
|
214
|
$dumper->Terse(1); |
86
|
|
|
|
|
|
|
|
87
|
8
|
|
|
|
|
96
|
return $dumper->Dump(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 path_as_filename |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
sub path_as_filename { |
94
|
8
|
|
|
8
|
1
|
22960
|
my ($self) = @_; |
95
|
|
|
|
|
|
|
|
96
|
8
|
|
|
|
|
66
|
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; |