line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Yeb::Context; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
65
|
$Yeb::Context::AUTHORITY = 'cpan:GETTY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Storage for context of request |
6
|
|
|
|
|
|
|
$Yeb::Context::VERSION = '0.103'; |
7
|
2
|
|
|
2
|
|
14
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
19
|
|
8
|
2
|
|
|
2
|
|
6665
|
use Plack::Request; |
|
2
|
|
|
|
|
197889
|
|
|
2
|
|
|
|
|
86
|
|
9
|
2
|
|
|
2
|
|
30
|
use URI; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
978
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has env => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
7
|
|
656
|
has stash => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
builder => sub {{}}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
|
664
|
has export => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
|
|
|
|
|
|
builder => sub {{}}, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
11
|
|
|
11
|
|
952
|
has header => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
lazy => 1, |
31
|
|
|
|
|
|
|
builder => sub {{}}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has request => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
lazy => 1, |
37
|
0
|
|
|
0
|
|
0
|
builder => sub { Plack::Request->new(shift->env) }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has uri_base => ( |
41
|
|
|
|
|
|
|
is => 'rw', |
42
|
|
|
|
|
|
|
lazy => 1, |
43
|
0
|
|
|
0
|
|
0
|
builder => sub { shift->request->base }, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub uri_for { # TODO supporting several args and hash as args |
47
|
0
|
|
|
0
|
0
|
0
|
my($self, $path, $args) = @_; |
48
|
0
|
|
|
|
|
0
|
my $uri = $self->uri_base; |
49
|
0
|
|
|
|
|
0
|
$uri->path($uri->path . $path); |
50
|
0
|
0
|
|
|
|
0
|
$uri->query_form(@$args) if $args; |
51
|
0
|
|
|
|
|
0
|
$uri; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has status => ( |
55
|
|
|
|
|
|
|
is => 'rw', |
56
|
|
|
|
|
|
|
lazy => 1, |
57
|
9
|
|
|
9
|
|
838
|
builder => sub { 200 }, |
58
|
|
|
|
|
|
|
predicate => 1, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has body => ( |
62
|
|
|
|
|
|
|
is => 'rw', |
63
|
|
|
|
|
|
|
lazy => 1, |
64
|
2
|
|
|
2
|
|
34
|
builder => sub { "Nothing todo, i am out of here" }, |
65
|
|
|
|
|
|
|
predicate => 1, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has content_type => ( |
69
|
|
|
|
|
|
|
is => 'rw', |
70
|
|
|
|
|
|
|
lazy => 1, |
71
|
2
|
|
|
2
|
|
93
|
builder => sub { "text/html" }, |
72
|
|
|
|
|
|
|
predicate => 1, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub response { |
76
|
11
|
|
|
11
|
0
|
24
|
my $self = shift; |
77
|
|
|
|
|
|
|
[ |
78
|
11
|
|
|
|
|
303
|
$self->status, |
79
|
|
|
|
|
|
|
[ |
80
|
|
|
|
|
|
|
content_type => $self->content_type, |
81
|
11
|
|
|
|
|
306
|
%{$self->header}, |
82
|
|
|
|
|
|
|
], |
83
|
|
|
|
|
|
|
[ $self->body ] |
84
|
|
|
|
|
|
|
] |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |