| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Thunderhorse::Controller; |
|
2
|
|
|
|
|
|
|
$Thunderhorse::Controller::VERSION = '0.102'; |
|
3
|
21
|
|
|
21
|
|
825957
|
use v5.40; |
|
|
21
|
|
|
|
|
89
|
|
|
4
|
21
|
|
|
21
|
|
129
|
use Mooish::Base -standard; |
|
|
21
|
|
|
|
|
44
|
|
|
|
21
|
|
|
|
|
232
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
21
|
|
|
21
|
|
336188
|
use Thunderhorse::Context::Facade; |
|
|
21
|
|
|
|
|
1429
|
|
|
|
21
|
|
|
|
|
1655
|
|
|
7
|
21
|
|
|
21
|
|
4425
|
use URI; |
|
|
21
|
|
|
|
|
33688
|
|
|
|
21
|
|
|
|
|
23813
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Gears::Controller'; |
|
10
|
|
|
|
|
|
|
with 'Thunderhorse::Autoloadable'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has extended 'app' => ( |
|
13
|
|
|
|
|
|
|
handles => [ |
|
14
|
|
|
|
|
|
|
qw( |
|
15
|
|
|
|
|
|
|
loop |
|
16
|
|
|
|
|
|
|
config |
|
17
|
|
|
|
|
|
|
) |
|
18
|
|
|
|
|
|
|
], |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
96
|
|
|
|
|
176
|
sub make_facade ($self, $ctx) |
|
22
|
96
|
|
|
96
|
0
|
145
|
{ |
|
|
96
|
|
|
|
|
141
|
|
|
|
96
|
|
|
|
|
134
|
|
|
23
|
96
|
|
|
|
|
1942
|
return Thunderhorse::Context::Facade->new(context => $ctx); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub router ($self) |
|
27
|
62
|
|
|
62
|
1
|
14272
|
{ |
|
|
62
|
|
|
|
|
116
|
|
|
|
62
|
|
|
|
|
97
|
|
|
28
|
62
|
|
|
|
|
439
|
my $router = $self->app->router; |
|
29
|
62
|
|
|
|
|
1353
|
$router->set_controller($self); |
|
30
|
62
|
|
|
|
|
1992
|
return $router; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
16
|
|
|
|
|
29
|
sub _run_method ($self, $method, @args) |
|
|
16
|
|
|
|
|
27
|
|
|
34
|
16
|
|
|
16
|
|
170
|
{ |
|
|
16
|
|
|
|
|
33
|
|
|
|
16
|
|
|
|
|
25
|
|
|
35
|
16
|
50
|
|
|
|
51
|
die "no such method $method" |
|
36
|
|
|
|
|
|
|
unless ref $self; |
|
37
|
|
|
|
|
|
|
|
|
38
|
16
|
|
|
|
|
84
|
my $module_method = $self->app->extra_methods->{controller}{$method}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
16
|
100
|
|
|
|
83
|
die "no such method $method" |
|
41
|
|
|
|
|
|
|
unless $module_method; |
|
42
|
|
|
|
|
|
|
|
|
43
|
13
|
|
|
|
|
51
|
return $module_method->($self, @args); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
5
|
sub _can_method ($self, $method) |
|
47
|
1
|
|
|
1
|
|
3
|
{ |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
48
|
1
|
|
|
|
|
41
|
return $self->app->extra_methods->{controller}{$method}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
10
|
|
|
|
|
17
|
sub url_for ($self, $name, @args) |
|
|
10
|
|
|
|
|
20
|
|
|
52
|
10
|
|
|
10
|
1
|
21165
|
{ |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
19
|
|
|
53
|
10
|
|
|
|
|
38
|
my $loc = $self->router->find($name); |
|
54
|
10
|
100
|
|
|
|
52
|
Gears::X::Thunderhorse->raise("no such route '$name'") |
|
55
|
|
|
|
|
|
|
unless defined $loc; |
|
56
|
|
|
|
|
|
|
|
|
57
|
8
|
|
|
|
|
58
|
return $loc->build(@args); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
6
|
|
|
|
|
12
|
sub abs_url ($self, $url = '') |
|
|
6
|
|
|
|
|
17
|
|
|
61
|
6
|
|
|
6
|
1
|
23299
|
{ |
|
|
6
|
|
|
|
|
10
|
|
|
62
|
6
|
|
|
|
|
198
|
return URI->new_abs( |
|
63
|
|
|
|
|
|
|
$url, |
|
64
|
|
|
|
|
|
|
$self->config->get('app_url', 'http://localhost:5000'), |
|
65
|
|
|
|
|
|
|
)->as_string; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
6
|
sub abs_url_for ($self, $name, @args) |
|
|
3
|
|
|
|
|
7
|
|
|
69
|
3
|
|
|
3
|
1
|
4899
|
{ |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
6
|
|
|
70
|
3
|
|
|
|
|
10
|
return $self->abs_url($self->url_for($name, @args)); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
13
|
|
|
|
|
22
|
sub render_error ($self, $ctx, $code, $message = undef) |
|
|
13
|
|
|
|
|
146
|
|
|
|
13
|
|
|
|
|
27
|
|
|
74
|
13
|
|
|
13
|
1
|
93
|
{ |
|
|
13
|
|
|
|
|
30
|
|
|
|
13
|
|
|
|
|
19
|
|
|
75
|
13
|
|
|
|
|
97
|
$self->app->render_error($self, $ctx, $code, $message); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
58
|
|
|
|
|
81
|
sub render_response ($self, $ctx, $result) |
|
|
58
|
|
|
|
|
104
|
|
|
79
|
58
|
|
|
58
|
1
|
89
|
{ |
|
|
58
|
|
|
|
|
89
|
|
|
|
58
|
|
|
|
|
76
|
|
|
80
|
58
|
|
|
|
|
409
|
$self->app->render_response($self, $ctx, $result); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
##################### |
|
84
|
|
|
|
|
|
|
### HOOKS SECTION ### |
|
85
|
|
|
|
|
|
|
##################### |
|
86
|
|
|
|
|
|
|
|
|
87
|
14
|
|
|
|
|
25
|
sub _on_error ($self, @args) |
|
88
|
14
|
|
|
14
|
|
30
|
{ |
|
|
14
|
|
|
|
|
38
|
|
|
|
14
|
|
|
|
|
32
|
|
|
89
|
14
|
|
|
|
|
214
|
$self->app->_fire_hooks(error => $self, @args); |
|
90
|
14
|
|
|
|
|
348
|
return $self->on_error(@args); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
13
|
|
|
|
|
22
|
sub on_error ($self, $ctx, $error) |
|
|
13
|
|
|
|
|
27
|
|
|
94
|
13
|
|
|
13
|
1
|
28
|
{ |
|
|
13
|
|
|
|
|
53
|
|
|
|
13
|
|
|
|
|
26
|
|
|
95
|
13
|
|
|
|
|
100
|
return $self->app->on_error($self, $ctx, $error); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |