line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::REST::Util; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Plack::Middleware::REST::Util::VERSION = '0.03'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
#ABSTRACT: Utility methods to create RESTful PSGI applications |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
86726
|
use Plack::Request; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw(request_id request_content request_uri); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub request_id { |
14
|
7
|
|
50
|
7
|
0
|
958
|
substr($_[0]->{PATH_INFO} || '/',1) |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub request_content { |
18
|
3
|
50
|
|
3
|
0
|
26
|
return unless defined $_[0]->{CONTENT_LENGTH}; |
19
|
3
|
|
|
|
|
20
|
return (Plack::Request->new($_[0])->content => $_[0]->{CONTENT_TYPE}); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub request_uri { |
23
|
4
|
|
|
4
|
0
|
2014
|
my $env = shift; |
24
|
4
|
50
|
|
|
|
17
|
my $id = @_ ? shift : request_id($env); |
25
|
4
|
|
|
|
|
41
|
my $uri = Plack::Request->new($env)->base; |
26
|
4
|
50
|
|
|
|
582
|
$uri .= '/' unless $uri =~ qr{/$}; |
27
|
4
|
|
|
|
|
40
|
return $uri . $id; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |