line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::RestAPI::Endpoint; |
2
|
9
|
|
|
9
|
|
36
|
use Moo; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
78
|
|
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
2294
|
use Types::Standard qw(Enum Str); |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
40
|
|
5
|
9
|
|
|
9
|
|
3571
|
use Data::Dumper; |
|
9
|
|
|
|
|
4191
|
|
|
9
|
|
|
|
|
433
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
3303
|
use parent 'Exporter'; |
|
9
|
|
|
|
|
2154
|
|
|
9
|
|
|
|
|
35
|
|
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
|
21
|
my ($path) = @_; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
62
|
$path =~ s/\W+/_/g; |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
|
|
|
41
|
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
|
44
|
my ($self) = @_; |
82
|
|
|
|
|
|
|
|
83
|
8
|
|
|
|
|
84
|
my $dumper = Data::Dumper->new([$self->render]); |
84
|
8
|
|
|
|
|
320
|
$dumper->Indent(0); |
85
|
8
|
|
|
|
|
170
|
$dumper->Terse(1); |
86
|
|
|
|
|
|
|
|
87
|
8
|
|
|
|
|
58
|
return $dumper->Dump(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 path_as_filename |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
sub path_as_filename { |
94
|
8
|
|
|
8
|
1
|
14578
|
my ($self) = @_; |
95
|
|
|
|
|
|
|
|
96
|
8
|
|
|
|
|
44
|
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; |