line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::OAuth::GenericHandler; |
2
|
2
|
|
|
2
|
|
924
|
use parent qw(Plack::Request); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
3
|
2
|
|
|
2
|
|
130
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
5
|
2
|
|
|
2
|
|
1726
|
use YAML::Any; |
|
2
|
|
|
|
|
2433
|
|
|
2
|
|
|
|
|
15
|
|
6
|
2
|
|
|
2
|
|
31828
|
use JSON::Any; |
|
2
|
|
|
|
|
9377
|
|
|
2
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $json_any; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub run { |
11
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
12
|
|
|
|
|
|
|
# get method or post method ? |
13
|
0
|
|
|
|
|
|
my $res; |
14
|
0
|
0
|
|
|
|
|
$res = $self->get if $self->method eq 'GET'; |
15
|
0
|
0
|
|
|
|
|
return $res if $res; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
$res = $self->post if $self->method eq 'POST'; |
18
|
0
|
0
|
|
|
|
|
return $res if $res; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$res = $self->any; |
21
|
0
|
0
|
|
|
|
|
return $res if $res; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
return $self->render( ref($self) . ': handler is not defined.' ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# get method handler |
28
|
0
|
|
|
0
|
1
|
|
sub get { } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# get post handler |
31
|
0
|
|
|
0
|
1
|
|
sub post { } |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub any { } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# default content_type |
36
|
0
|
|
|
0
|
1
|
|
sub content_type { 'text/html' } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub to_json { |
39
|
0
|
|
|
0
|
1
|
|
my ($self, $obj) = @_; |
40
|
0
|
|
0
|
|
|
|
$json_any ||= JSON::Any->new; |
41
|
0
|
|
|
|
|
|
return $self->render( $json_any->encode($obj) , 'text/json' ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub to_yaml { |
45
|
0
|
|
|
0
|
1
|
|
my ($self, $obj) = @_; |
46
|
0
|
|
|
|
|
|
return $self->render( Dump( $obj ) , 'text/plain' ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub render { |
50
|
0
|
|
|
0
|
1
|
|
my ($self,$body,$content_type) = @_; |
51
|
0
|
|
|
|
|
|
my $resp = $self->new_response( 200 ); |
52
|
0
|
|
0
|
|
|
|
$resp->content_type( $content_type || $self->content_type ); |
53
|
0
|
|
|
|
|
|
$resp->body( $body ); |
54
|
0
|
|
|
|
|
|
return $resp->finalize; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub redirect { |
58
|
0
|
|
|
0
|
1
|
|
my ($self,$uri,$code) = @_; |
59
|
0
|
|
|
|
|
|
my $resp = $self->new_response( $code ); |
60
|
0
|
|
|
|
|
|
$resp->redirect( $uri ); |
61
|
0
|
|
|
|
|
|
return $resp->finalize; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |