line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
#PODNAME: Raisin::Request |
3
|
|
|
|
|
|
|
#ABSTRACT: Request class for Raisin. |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
78
|
use strict; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
318
|
|
6
|
12
|
|
|
12
|
|
53
|
use warnings; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
473
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Raisin::Request; |
9
|
|
|
|
|
|
|
$Raisin::Request::VERSION = '0.94'; |
10
|
12
|
|
|
12
|
|
67
|
use parent 'Plack::Request'; |
|
12
|
|
|
|
|
49
|
|
|
12
|
|
|
|
|
64
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub prepare_params { |
13
|
41
|
|
|
41
|
1
|
333
|
my ($self, $declared, $named) = @_; |
14
|
|
|
|
|
|
|
|
15
|
41
|
|
|
|
|
106
|
$self->{'raisin.declared'} = $declared; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# PRECEDENCE: |
18
|
|
|
|
|
|
|
# - path |
19
|
|
|
|
|
|
|
# - query |
20
|
|
|
|
|
|
|
# - body |
21
|
|
|
|
|
|
|
my %params = ( |
22
|
41
|
100
|
|
|
|
106
|
%{ $self->env->{'raisinx.body_params'} || {} }, |
23
|
41
|
50
|
|
|
|
319
|
%{ $self->query_parameters->as_hashref_mixed || {} }, |
24
|
41
|
100
|
|
|
|
130
|
%{ $named || {} }, |
|
41
|
|
|
|
|
3241
|
|
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
41
|
|
|
|
|
126
|
$self->{'raisin.parameters'} = \%params; |
28
|
|
|
|
|
|
|
|
29
|
41
|
|
|
|
|
61
|
my $retval = 1; |
30
|
|
|
|
|
|
|
|
31
|
41
|
|
|
|
|
91
|
foreach my $p (@$declared) { |
32
|
69
|
|
|
|
|
155
|
my $name = $p->name; |
33
|
69
|
|
|
|
|
246
|
my $value = $params{$name}; |
34
|
|
|
|
|
|
|
|
35
|
69
|
100
|
|
|
|
148
|
if (not $p->validate(\$value)) { |
36
|
3
|
|
|
|
|
6
|
$retval = 0; |
37
|
3
|
100
|
|
|
|
11
|
$p->required ? return : next; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
66
|
100
|
100
|
|
|
145
|
$value //= $p->default if defined $p->default; |
41
|
66
|
100
|
|
|
|
314
|
next if not defined($value); |
42
|
|
|
|
|
|
|
|
43
|
58
|
|
|
|
|
152
|
$self->{'raisin.declared_params'}{$name} = $value; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
39
|
|
|
|
|
130
|
$retval; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
35
|
|
|
35
|
1
|
137
|
sub declared_params { shift->{'raisin.declared_params'} } |
50
|
4
|
|
|
4
|
1
|
30
|
sub raisin_parameters { shift->{'raisin.parameters'} } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |