line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Che; |
2
|
1
|
|
|
1
|
|
75756
|
use Mojo::Base::Che; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
47
|
|
3
|
1
|
|
|
1
|
|
8
|
use Mojo::Base 'Mojolicious'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
900
|
use Mojo::Log::Che; |
|
1
|
|
|
|
|
43
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
49
|
use Mojo::Loader qw(load_class); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2741
|
|
6
|
|
|
|
|
|
|
#~ use Mojo::Util qw(url_unescape); |
7
|
|
|
|
|
|
|
#~ use Scalar::Util 'weaken'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
1
|
|
my ($class, %args) = @_; |
11
|
0
|
|
0
|
|
|
|
my $config = delete($args{config}) || 'Config.pm'; |
12
|
0
|
|
|
|
|
|
my $app = $class->SUPER::new(%args); |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
$app->plugin(Config =>{file => $config}); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#~ return $app # остановка или двойной перезапуск kill -USR2 |
17
|
|
|
|
|
|
|
#~ if $ENV{HYPNOTOAD_PID} || $ENV{HYPNOTOAD_STOP}; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $conf = $app->config; |
20
|
0
|
|
0
|
|
|
|
$conf->{mojo} ||= {}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
0
|
|
|
|
my $defaults = $conf->{'mojo_defaults'} || $conf->{'mojo'}{'defaults'} || $conf->{'mojo.defaults'}; |
23
|
0
|
0
|
|
|
|
|
$app->defaults($defaults) |
24
|
|
|
|
|
|
|
if $defaults; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
0
|
|
|
|
my $secret = $conf->{'mojo_secret'} || $conf->{'mojo_secrets'} || $conf->{'mojo'}{'secret'} || $conf->{'mojo'}{'secrets'} || $conf->{'mojo.secret'} || $conf->{'mojo.secrets'} || $conf->{'шифры'} || [rand]; |
27
|
0
|
|
|
|
|
|
$app->secrets($secret); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
0
|
|
|
|
my $mode = $conf->{'mojo_mode'} || $conf->{'mojo'}{'mode'} || $conf->{'mojo.mode'}; |
30
|
0
|
0
|
|
|
|
|
$app->mode($mode) # Файл лога уже не переключишь |
31
|
|
|
|
|
|
|
if $mode; |
32
|
|
|
|
|
|
|
#~ $app->log->level( $conf->{'mojo_log_level'} || $conf->{'mojo'}{'log_level'} || 'debug'); |
33
|
0
|
|
0
|
|
|
|
my $log = $conf->{'mojo_log'} || $conf->{'mojo.log'} || $conf->{'mojo'}{'log'}; |
34
|
0
|
0
|
|
|
|
|
$app->log(Mojo::Log::Che->new(%$log)) |
35
|
|
|
|
|
|
|
if $log; |
36
|
|
|
|
|
|
|
#~ warn "Mode: ", $app->mode, "; log level: ", $app->log->level; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $home = $app->home; |
39
|
0
|
|
0
|
|
|
|
my $statics = $conf->{'mojo_static_paths'} || $conf->{'mojo.static.paths'} || $conf->{'mojo'}{'static'}{'paths'} || []; |
40
|
|
|
|
|
|
|
#~ push @{$app->static->paths}, @{$paths} if $paths; |
41
|
0
|
|
|
|
|
|
push @{$app->static->paths}, $home->rel_file($_) |
42
|
0
|
|
|
|
|
|
for @$statics; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
0
|
|
|
|
my $templates_paths = $conf->{'mojo_renderer_paths'} || $conf->{'mojo.renderer.paths'} || $conf->{'mojo'}{'renderer'}{'paths'} || []; |
45
|
0
|
|
|
|
|
|
push @{$app->renderer->paths}, $home->rel_dir($_) |
46
|
0
|
|
|
|
|
|
for @$templates_paths; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
0
|
|
|
|
my $renderer_classes = $conf->{'mojo_renderer_classes'} || $conf->{'mojo.renderer.classes'} || $conf->{'mojo'}{'renderer'}{'classes'} || []; |
49
|
0
|
|
|
|
|
|
push @{$app->renderer->classes}, $_ |
50
|
0
|
|
|
|
|
|
for grep ! load_class($_), @$renderer_classes; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$app->сессия(); |
53
|
0
|
|
|
|
|
|
$app->хазы(); |
54
|
0
|
|
|
|
|
|
$app->плугины(); |
55
|
0
|
|
|
|
|
|
$app->хуки(); |
56
|
0
|
|
|
|
|
|
$app->спейсы(); |
57
|
0
|
|
|
|
|
|
$app->маршруты(); |
58
|
0
|
|
|
|
|
|
$app->задачи(); |
59
|
0
|
|
|
|
|
|
$app->типы(); |
60
|
|
|
|
|
|
|
#~ $app->minion_worker(); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $app; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub хазы { # Хазы из конфига |
67
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
68
|
0
|
|
|
|
|
|
my $conf = $app->config; |
69
|
0
|
|
0
|
|
|
|
my $h = $conf->{'mojo_has'} || $conf->{'mojo.has'} || $conf->{'mojo'}{'has'} || $conf->{'хазы'}; |
70
|
|
|
|
|
|
|
map { |
71
|
0
|
|
|
|
|
|
$app->log->debug("Make the app->has('$_')"); |
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
has $_ => $h->{$_}; |
73
|
|
|
|
|
|
|
} keys %$h; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#~ sub плугины {# Плугины из конфига |
77
|
|
|
|
|
|
|
has плугины => sub { |
78
|
|
|
|
|
|
|
my $app = shift; |
79
|
|
|
|
|
|
|
my $conf = $app->config; |
80
|
|
|
|
|
|
|
my $плугины = {}; |
81
|
|
|
|
|
|
|
my $plugins = $conf->{'mojo_plugins'} || $conf->{'mojo.plugins'} || $conf->{'mojo'}{'plugins'} || $conf->{'плугины'} |
82
|
|
|
|
|
|
|
|| return; |
83
|
|
|
|
|
|
|
map { |
84
|
|
|
|
|
|
|
push @{ $плугины->{$_->[0]} ||= [] }, [ref $_->[1] eq 'CODE' ? $app->plugin($_->[0] => $app->${ \$_->[1] }) : $app->plugin(@$_)]; |
85
|
|
|
|
|
|
|
$app->log->debug("Enable plugin [$_->[0]]"); |
86
|
|
|
|
|
|
|
} @$plugins; |
87
|
|
|
|
|
|
|
return $плугины; |
88
|
|
|
|
|
|
|
}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub хуки {# Хуки из конфига |
92
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
93
|
0
|
|
|
|
|
|
my $conf = $app->config; |
94
|
0
|
|
0
|
|
|
|
my $hooks = $conf->{'mojo_hooks'} || $conf->{'mojo.hooks'} || $conf->{'mojo'}{'hooks'} || $conf->{'хуки'} |
95
|
|
|
|
|
|
|
|| return; |
96
|
0
|
|
|
|
|
|
while (my ($name, $sub) = each %$hooks) { |
97
|
0
|
0
|
|
|
|
|
if (ref $sub eq 'ARRAY') { |
98
|
|
|
|
|
|
|
$app->hook($name => $_) |
99
|
0
|
|
|
|
|
|
for @$sub; |
100
|
|
|
|
|
|
|
} else { |
101
|
0
|
|
|
|
|
|
$app->hook($name => $sub); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
$app->log->debug(sprintf("Applied hook%s [%s] from config", ref $sub eq 'ARRAY' ? "s (@{[ scalar @$sub]})" : '', $name)); |
|
0
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub сессия { |
110
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
111
|
0
|
|
|
|
|
|
my $conf = $app->config; |
112
|
0
|
|
0
|
|
|
|
my $session = $conf->{'mojo_session'} || $conf->{'mojo_sessions'} || $conf->{'mojo.session'} || $conf->{'mojo.sessions'} || $conf->{'mojo'}{'session'} || $conf->{'mojo'}{'sessions'} || $conf->{'сессии'} || $conf->{'сессия'} |
113
|
|
|
|
|
|
|
|| return; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#~ $app->sessions->cookie_name($session->{'cookie_name'}) |
116
|
|
|
|
|
|
|
#~ if $session->{'cookie_name'}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#~ $app->sessions->default_expiration($session->{'default_expiration'}) # set expiry |
119
|
|
|
|
|
|
|
#~ if defined $session->{'default_expiration'}; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
while (my ($meth, $val) = each %$session) { |
122
|
|
|
|
|
|
|
next |
123
|
0
|
0
|
|
|
|
|
unless $app->sessions->can($meth); |
124
|
0
|
|
|
|
|
|
$app->sessions->$meth($val); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub маршруты { |
129
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
130
|
0
|
|
|
|
|
|
my $conf = $app->config; |
131
|
0
|
0
|
0
|
|
|
|
my $routes = $conf->{'mojo_routes'} || $conf->{'mojo.routes'} || $conf->{'mojo'}{'routes'} || $conf->{'routes'} || $conf->{'маршруты'} |
132
|
|
|
|
|
|
|
or return; |
133
|
0
|
|
|
|
|
|
my $app_routes = $app->routes; |
134
|
|
|
|
|
|
|
my $apply_route = sub { |
135
|
0
|
|
0
|
0
|
|
|
my $r = shift || $app_routes; |
136
|
0
|
|
|
|
|
|
my ($meth, $arg) = @_; |
137
|
0
|
|
|
|
|
|
my $nr; |
138
|
0
|
0
|
|
|
|
|
if (my $m = $r->can($meth)) { |
139
|
0
|
0
|
|
|
|
|
$nr = $r->$m($arg) unless ref($arg); |
140
|
0
|
0
|
|
|
|
|
$nr = $r->$m(cb => $arg) if ref($arg) eq 'CODE'; |
141
|
0
|
0
|
|
|
|
|
$nr = $r->$m(@$arg) if ref($arg) eq 'ARRAY'; |
142
|
0
|
0
|
|
|
|
|
$nr = $r->$m(%$arg) if ref($arg) eq 'HASH'; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} else { |
145
|
0
|
|
|
|
|
|
$app->log->warn("Can't method [$meth] for route",); |
146
|
|
|
|
|
|
|
} |
147
|
0
|
|
|
|
|
|
return $nr; |
148
|
0
|
|
|
|
|
|
}; |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
for my $r (@$routes) { |
151
|
0
|
0
|
|
|
|
|
my $nr = $apply_route->($app_routes, @$r[0,1]) |
152
|
|
|
|
|
|
|
or next; |
153
|
0
|
|
|
|
|
|
$app->log->debug("Apply route [$r->[0] $r->[1]]"); |
154
|
0
|
|
|
|
|
|
for( my $i = 2; $i < @$r; $i += 2 ) { |
155
|
0
|
0
|
|
|
|
|
$nr = $apply_route->($nr, @$r[$i, $i+1]) |
156
|
|
|
|
|
|
|
or next; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub спейсы { |
162
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
163
|
0
|
|
|
|
|
|
my $conf = $app->config; |
164
|
0
|
|
0
|
|
|
|
my $ns = $conf->{'mojo_namespaces'} || $conf->{'mojo.namespaces'} || $conf->{'mojo'}{'namespaces'} || $conf->{'namespaces'} || $conf->{'ns'} || $conf->{'спейсы'} |
165
|
|
|
|
|
|
|
|| return; |
166
|
0
|
|
|
|
|
|
push @{$app->routes->namespaces}, @$ns; |
|
0
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub задачи { |
170
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
171
|
0
|
|
|
|
|
|
my $conf = $app->config; |
172
|
0
|
0
|
0
|
|
|
|
my $tasks = $conf->{'jobs'} || $conf->{'tasks'} || $conf->{'задачи'} |
173
|
|
|
|
|
|
|
or return; |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
die "You have jobs and first enable plugin Minion" |
176
|
|
|
|
|
|
|
unless $app->renderer->get_helper('minion'); |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
while (my ($name, $sub) = each %$tasks) { |
179
|
0
|
|
|
|
|
|
$app->log->debug(sprintf("Applied task [%s] in [%s] from config", $name, $app->minion->add_task($name => $sub))); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
#~ $app->minion->reset; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub типы {#MIME |
186
|
0
|
|
|
0
|
0
|
|
my $app = shift; |
187
|
0
|
|
|
|
|
|
my $conf = $app->config; |
188
|
0
|
0
|
0
|
|
|
|
my $types = $conf->{'mojo_types'} || $conf->{'mojo.types'} || $conf->{'mojo'}{'types'} || $conf->{'types'} || $conf->{'типы'} |
189
|
|
|
|
|
|
|
or return; |
190
|
0
|
|
|
|
|
|
while (my ($name, $val) = each %$types) { |
191
|
0
|
|
|
|
|
|
$app->types->type($name => $val); |
192
|
0
|
|
|
|
|
|
$app->log->debug(sprintf("Applied type [%s] from config", $name)); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# overide only on my $path = $req->url->path->to_abs_string; |
197
|
|
|
|
|
|
|
sub Mojolicious::dispatch { |
198
|
0
|
|
|
0
|
1
|
|
my ($self, $c) = @_; |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my $plugins = $self->plugins->emit_hook(before_dispatch => $c); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# Try to find a static file |
203
|
0
|
|
|
|
|
|
my $tx = $c->tx; |
204
|
0
|
0
|
0
|
|
|
|
$self->static->dispatch($c) and $plugins->emit_hook(after_static => $c) |
205
|
|
|
|
|
|
|
unless $tx->res->code; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# Start timer (ignore static files) |
208
|
0
|
|
|
|
|
|
my $stash = $c->stash; |
209
|
|
|
|
|
|
|
$c->helpers->log->debug(sub { |
210
|
0
|
|
|
0
|
|
|
my $req = $c->req; |
211
|
0
|
|
|
|
|
|
my $url = $req->url->to_abs; |
212
|
0
|
|
|
|
|
|
$c->helpers->timing->begin('mojo.timer'); |
213
|
|
|
|
|
|
|
#~ return sprintf qq{[%s] %s "%s://%s%s%s"}, |
214
|
|
|
|
|
|
|
#~ $req->request_id, $req->method, $url->scheme, $url->host, $url->port ? ":".$url->port : '', $url->path->to_route; |
215
|
0
|
|
|
|
|
|
return sprintf qq{%s "%s"}, $req->method, Mojo::Util::decode('UTF-8', Mojo::Util::url_unescape($url)); |
216
|
0
|
0
|
|
|
|
|
}) unless $stash->{'mojo.static'}; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# Routes |
219
|
0
|
|
|
|
|
|
$plugins->emit_hook(before_routes => $c); |
220
|
|
|
|
|
|
|
$c->helpers->reply->not_found |
221
|
0
|
0
|
0
|
|
|
|
unless $tx->res->code || $self->routes->dispatch($c) || $tx->res->code || $stash->{'mojo.rendered'}; |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
our $VERSION = '0.09191';# as to Mojolicious/100+0.000 |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=pod |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=encoding utf8 |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 Mojolicious::Che |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Доброго всем |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! ! |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 VERSION |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
0.09191 |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 NAME |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Mojolicious::Che - Мой базовый модуль для приложений Mojolicious. Нужен только развернутый конфиг. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 SYNOPSIS |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
# app.pl |
248
|
|
|
|
|
|
|
use lib 'lib'; |
249
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious::Che'; |
250
|
|
|
|
|
|
|
__PACKAGE__->new(config => 'lib/Config.pm')->start(); |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 Config file |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Порядок строк в этом конфиге соответствует исполнению в модуле! |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
{ |
258
|
|
|
|
|
|
|
'Проект'=>'Тест-проект', |
259
|
|
|
|
|
|
|
# mojo => { |
260
|
|
|
|
|
|
|
# defaults => |
261
|
|
|
|
|
|
|
# secrets => |
262
|
|
|
|
|
|
|
# mode=> |
263
|
|
|
|
|
|
|
# log => {level=>...} |
264
|
|
|
|
|
|
|
# static => {paths => [...]}, |
265
|
|
|
|
|
|
|
# renderer => {paths => [...], classes => [...], }, |
266
|
|
|
|
|
|
|
# session[s] => |
267
|
|
|
|
|
|
|
# has => |
268
|
|
|
|
|
|
|
# plugins => |
269
|
|
|
|
|
|
|
# hooks => |
270
|
|
|
|
|
|
|
# namespaces => |
271
|
|
|
|
|
|
|
# routes => |
272
|
|
|
|
|
|
|
# jobs => |
273
|
|
|
|
|
|
|
# types => |
274
|
|
|
|
|
|
|
# }, |
275
|
|
|
|
|
|
|
# or with prefix mojo_ |
276
|
|
|
|
|
|
|
# Default values for "stash" in Mojolicious::Controller, assigned for every new request. |
277
|
|
|
|
|
|
|
mojo_defaults => {layout=>'default',}, |
278
|
|
|
|
|
|
|
# 'шифры' => [ |
279
|
|
|
|
|
|
|
mojo_secrets => ['true 123 my app',], |
280
|
|
|
|
|
|
|
mojo_mode=> 'development', |
281
|
|
|
|
|
|
|
mojo_log=>{level => 'error'}, |
282
|
|
|
|
|
|
|
mojo_static_paths => ["static"], |
283
|
|
|
|
|
|
|
mojo_renderer_classes => ["Mojolicious::Foo::Fun"], |
284
|
|
|
|
|
|
|
# 'сессия'(или сессии) => |
285
|
|
|
|
|
|
|
mojo_session[s] => {cookie_name => 'EXX', default_expiration => 86400}, |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# 'хазы' => 'Лет 500-700 назад был такой дикий степной торговый жадный народ ХАЗАРЫ. Столицей их "государства" был город Тьмутаракань, где-то на берегу моря Каспия. Потомки этих людей рассыпаны по странам России, Средней Азии, Европы. Есть мнение, что хазары присвоили себе название ЕВРЕИ, но это не те библейские кроткие евреи, а жадные потомки кроманьонцев' |
288
|
|
|
|
|
|
|
mojo_has => { |
289
|
|
|
|
|
|
|
foo => sub {my $app = shift; return 'is a bar';}, |
290
|
|
|
|
|
|
|
}, |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# 'плугины'=> [ |
293
|
|
|
|
|
|
|
mojo_plugins=>[ |
294
|
|
|
|
|
|
|
['Foo::Bar'], |
295
|
|
|
|
|
|
|
[Foo::Bar::Plugin => opt1 => ..., opt2 => ...], |
296
|
|
|
|
|
|
|
['Foo::Plugin' => sub {<...returns config data list...>}], |
297
|
|
|
|
|
|
|
], |
298
|
|
|
|
|
|
|
# 'хуки' => |
299
|
|
|
|
|
|
|
mojo_hooks=>{ |
300
|
|
|
|
|
|
|
#~ before_dispatch => sub {1;}, |
301
|
|
|
|
|
|
|
}, |
302
|
|
|
|
|
|
|
# 'спейсы' => [...] |
303
|
|
|
|
|
|
|
namespaces => ['Space::Shattle'], |
304
|
|
|
|
|
|
|
# 'маршруты' => [...] |
305
|
|
|
|
|
|
|
routes => [ |
306
|
|
|
|
|
|
|
[get=>'/', to=> {cb=>sub{shift->render(format=>'txt', text=>'Hello friend!');},}], |
307
|
|
|
|
|
|
|
] |
308
|
|
|
|
|
|
|
#~ 'задачи'=> {#first enable plugin Minion |
309
|
|
|
|
|
|
|
jobs => { |
310
|
|
|
|
|
|
|
slow_log => sub { |
311
|
|
|
|
|
|
|
my ($job, $msg) = @_; |
312
|
|
|
|
|
|
|
sleep 5; |
313
|
|
|
|
|
|
|
$job->app->log->error(qq{slow_log "$msg"}); |
314
|
|
|
|
|
|
|
}, |
315
|
|
|
|
|
|
|
}, |
316
|
|
|
|
|
|
|
# или 'типы'=>{...} |
317
|
|
|
|
|
|
|
types => { |
318
|
|
|
|
|
|
|
docx => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'], |
319
|
|
|
|
|
|
|
... |
320
|
|
|
|
|
|
|
}, |
321
|
|
|
|
|
|
|
}; |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
B inherits all attributes from L and implements the |
326
|
|
|
|
|
|
|
following new ones. |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head2 плугины |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Apply the plugins. See L, L. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head1 METHODS |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
B inherits all methods from L and implements the following new ones. |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=head2 сессия() |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
Session object config apply. See L, L. |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=head2 хазы() |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
Apply the has's. UTF names allow. |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=head2 хуки() |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
Apply the hooks. See L. |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=head2 спейсы() |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Apply the namespaces. Push @{$app->routes->namespaces} your namespaces. See L. |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
namespaces => ['Space::Shattle'], |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=head2 маршруты() |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
Apply the routes. See L, L. |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
#~ 'маршруты' => [ |
359
|
|
|
|
|
|
|
'routes'=>[ |
360
|
|
|
|
|
|
|
[get=>'/', to=> {cb=>sub{shift->render(format=>'txt', text=>'Welcome!');},}], |
361
|
|
|
|
|
|
|
], |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=head2 задачи() |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
Apply the jobs. See L. |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
#~ 'задачи'=> {#first enable plugin Minion |
368
|
|
|
|
|
|
|
'jobs'=> { # or tasks |
369
|
|
|
|
|
|
|
slow_log => sub { |
370
|
|
|
|
|
|
|
my ($job, $msg) = @_; |
371
|
|
|
|
|
|
|
sleep 5; |
372
|
|
|
|
|
|
|
$job->app->log->error(qq{slow_log "$msg"}); |
373
|
|
|
|
|
|
|
}, |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
}, |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=head типы() |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
Apply the new types. See L, L. |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head1 SEE ALSO |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
L |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
L |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=head1 AUTHOR |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
Михаил Че (Mikhail Che), C<< >> |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=head1 BUGS / CONTRIBUTING |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
Please report any bugs or feature requests at L. |
394
|
|
|
|
|
|
|
Pull requests also welcome. |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=head1 COPYRIGHT |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
Copyright 2016+ Mikhail Che. |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
401
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=cut |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
1; |